Commit 47a0039d authored by rockyl's avatar rockyl

修改上传

parent 8d14d956
......@@ -3,7 +3,6 @@
*/
const path = require('path');
const fs = require('fs');
const gulp = require('gulp');
const glob = require('glob');
const rollup = require('rollup');
......@@ -11,14 +10,18 @@ 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');
const replace = require('rollup-plugin-replace');
const livereload = require('gulp-livereload');
const runSequence = require('run-sequence');
let currentMode = 'debug';
let version, releasePath;
let completeCallback;
let completeCallback, umdName;
exports.setCallback = function (callback) {
exports.setConfig = function (config) {
const {callback, name} = config;
completeCallback = callback;
umdName = name;
};
const tsPaths = ['**/*.ts'];
......@@ -28,13 +31,13 @@ const pathsConfig = tsconfig.compilerOptions.paths;
if (pathsConfig) {
for (let key in pathsConfig) {
let paths = pathsConfig[key];
for(let path of paths){
for (let path of paths) {
if (path[path.length - 1] === '*') {
path += '*/*.ts';
}else{
try{
} else {
try {
path = path.replace(/index$/, '**/*.ts')
}catch (e) {
} catch (e) {
console.log(e);
}
}
......@@ -43,17 +46,21 @@ if (pathsConfig) {
}
}
gulp.task('executeScripts', function(cb){
gulp.task('executeScripts', async function () {
const files = glob.sync("scripts/*.js");
for(const file of files){
for (const file of files) {
try {
const process = require(path.resolve(file));
process.execute();
}catch (e) {
await process.execute();
} catch (e) {
console.log(e);
}
}
cb();
});
gulp.task('copy-res', async function () {
gulp.src('resource/**/*')
.pipe(gulp.dest(path.join(releasePath, 'resource')))
});
gulp.task('compileTs', async function () {
......@@ -69,7 +76,21 @@ gulp.task('compileTs', async function () {
];
if (currentMode === 'build') {
plugins.push(uglify());
plugins.push(uglify({
//keep_fnames: true,
//toplevel: true,
mangle: {
//properties: true,
reserved: [umdName, 'startup', 'userAgent'],
}
}));
} else {
plugins.push(
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VUE_ENV': JSON.stringify('browser')
})
)
}
let file = currentMode === 'debug' ?
......@@ -78,7 +99,8 @@ gulp.task('compileTs', async function () {
let writeConfig = {
file,
format: 'cjs',
format: 'umd',
name: umdName,
};
if (currentMode === 'debug') {
......@@ -103,24 +125,26 @@ gulp.task('watch', function () {
livereload.listen({
quiet: true,
});
gulp.watch('src/**', ['compile']);
gulp.watch(['src/**', 'resource/**/*.+(scene|pfb)'], ['compile']);
});
gulp.task('dev', ['compile', 'watch'], function (cb) {
completeCallback && completeCallback('success');
//completeCallback && completeCallback('success');
cb();
});
gulp.task('compile', ['executeScripts', 'compileTs'], function (cb) {
completeCallback && completeCallback('success');
gulp.task('compile', function (cb) {
runSequence('executeScripts', 'compileTs', function () {
//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 () {
gulp.start(['compile', 'copy-res'], function () {
console.log('build success! \nversion:', version);
completeCallback && completeCallback(version);
});
......
......@@ -17,8 +17,11 @@ exports.setTsConfig = function (tsConfig){
//gulpConfig.setTsConfig(tsConfig);
};
exports.startGulpTask = function(tasks = ['default'], callback){
gulpConfig.setCallback(cb = callback);
exports.startGulpTask = function(tasks = ['default'], callback, name){
gulpConfig.setConfig({
callback: cb = callback,
name
});
const gulpInst = require('gulp');
logEvents(gulpInst);
......
......@@ -8,6 +8,9 @@ const {loadGulpFile, startGulpTask, setTsConfig} = require('./gulp-helper');
const gulpFile = path.resolve(__dirname, 'dev-config', 'gulpfile.js');
loadGulpFile(gulpFile);
const {name} = require(path.resolve('./project.json'));
console.log(name);
exports.runGulp = function (task) {
return new Promise((resolve, reject)=>{
startGulpTask([task], function(result){
......@@ -16,6 +19,6 @@ exports.runGulp = function (task) {
}else{
reject(result);
}
});
}, name);
})
};
......@@ -60,6 +60,14 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz",
"integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w=="
},
"ansi-cyan": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz",
"integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=",
"requires": {
"ansi-wrap": "0.1.0"
}
},
"ansi-gray": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz",
......@@ -68,6 +76,14 @@
"ansi-wrap": "0.1.0"
}
},
"ansi-red": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz",
"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
"requires": {
"ansi-wrap": "0.1.0"
}
},
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
......@@ -1997,6 +2013,52 @@
"through": "~2.3"
}
},
"plugin-error": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"requires": {
"ansi-cyan": "^0.1.1",
"ansi-red": "^0.1.1",
"arr-diff": "^1.0.1",
"arr-union": "^2.0.1",
"extend-shallow": "^1.1.2"
},
"dependencies": {
"arr-diff": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"requires": {
"arr-flatten": "^1.0.1",
"array-slice": "^0.2.3"
}
},
"arr-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0="
},
"array-slice": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU="
},
"extend-shallow": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"requires": {
"kind-of": "^1.1.0"
}
},
"kind-of": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ="
}
}
},
"posix-character-classes": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
......@@ -2161,6 +2223,26 @@
"resolve": "^1.1.6"
}
},
"rollup-plugin-replace": {
"version": "2.1.0",
"resolved": "http://registry.npm.taobao.org/rollup-plugin-replace/download/rollup-plugin-replace-2.1.0.tgz",
"integrity": "sha1-+cB6Somi+L6RLuVLPw9o2R6e0K4=",
"requires": {
"magic-string": "^0.25.1",
"minimatch": "^3.0.2",
"rollup-pluginutils": "^2.0.1"
},
"dependencies": {
"minimatch": {
"version": "3.0.4",
"resolved": "http://registry.npm.taobao.org/minimatch/download/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"requires": {
"brace-expansion": "^1.1.7"
}
}
}
},
"rollup-plugin-typescript2": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.18.0.tgz",
......@@ -2274,6 +2356,16 @@
}
}
},
"run-sequence": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/run-sequence/-/run-sequence-2.2.1.tgz",
"integrity": "sha512-qkzZnQWMZjcKbh3CNly2srtrkaO/2H/SI5f2eliMCapdRD3UhMrwjfOAZJAnZ2H8Ju4aBzFZkBGXUqFs9V0yxw==",
"requires": {
"chalk": "^1.1.3",
"fancy-log": "^1.3.2",
"plugin-error": "^0.1.2"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
......
......@@ -28,6 +28,13 @@
resolved "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz#4fa76e6598b7de3f0cb6ec3abacc4f59e5b3a2ce"
integrity sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==
ansi-cyan@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz#538ae528af8982f28ae30d86f2f17456d2609873"
integrity sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=
dependencies:
ansi-wrap "0.1.0"
ansi-gray@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251"
......@@ -35,6 +42,13 @@ ansi-gray@^0.1.1:
dependencies:
ansi-wrap "0.1.0"
ansi-red@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c"
integrity sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=
dependencies:
ansi-wrap "0.1.0"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
......@@ -62,6 +76,14 @@ archy@^1.0.0:
resolved "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=
arr-diff@^1.0.1:
version "1.1.0"
resolved "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz#687c32758163588fef7de7b36fabe495eb1a399a"
integrity sha1-aHwydYFjWI/vfeezb6vklesaOZo=
dependencies:
arr-flatten "^1.0.1"
array-slice "^0.2.3"
arr-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
......@@ -79,6 +101,11 @@ arr-flatten@^1.0.1, arr-flatten@^1.1.0:
resolved "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==
arr-union@^2.0.1:
version "2.1.0"
resolved "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz#20f9eab5ec70f5c7d215b1077b1c39161d292c7d"
integrity sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=
arr-union@^3.1.0:
version "3.1.0"
resolved "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
......@@ -94,6 +121,11 @@ array-each@^1.0.1:
resolved "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f"
integrity sha1-p5SvDAWrF1KEbudTofIRoFugxE8=
array-slice@^0.2.3:
version "0.2.3"
resolved "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5"
integrity sha1-3Tz7gO15c6dRF82sabC5nshhhvU=
array-slice@^1.0.0:
version "1.1.0"
resolved "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4"
......@@ -215,7 +247,7 @@ cache-base@^1.0.1:
union-value "^1.0.0"
unset-value "^1.0.0"
chalk@^1.0.0:
chalk@^1.0.0, chalk@^1.1.3:
version "1.1.3"
resolved "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=
......@@ -491,6 +523,13 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"
extend-shallow@^1.1.2:
version "1.1.4"
resolved "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz#19d6bf94dfc09d76ba711f39b872d21ff4dd9071"
integrity sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=
dependencies:
kind-of "^1.1.0"
extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
......@@ -1146,6 +1185,11 @@ jsonfile@^4.0.0:
optionalDependencies:
graceful-fs "^4.1.6"
kind-of@^1.1.0:
version "1.1.0"
resolved "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44"
integrity sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
version "3.2.2"
resolved "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
......@@ -1615,6 +1659,17 @@ pause-stream@0.0.11:
dependencies:
through "~2.3"
plugin-error@^0.1.2:
version "0.1.2"
resolved "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz#3b9bb3335ccf00f425e07437e19276967da47ace"
integrity sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=
dependencies:
ansi-cyan "^0.1.1"
ansi-red "^0.1.1"
arr-diff "^1.0.1"
arr-union "^2.0.1"
extend-shallow "^1.1.2"
posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
......@@ -1817,6 +1872,15 @@ rollup@^0.66.6:
"@types/estree" "0.0.39"
"@types/node" "*"
run-sequence@^2.2.1:
version "2.2.1"
resolved "https://registry.npmjs.org/run-sequence/-/run-sequence-2.2.1.tgz#1ce643da36fd8c7ea7e1a9329da33fc2b8898495"
integrity sha512-qkzZnQWMZjcKbh3CNly2srtrkaO/2H/SI5f2eliMCapdRD3UhMrwjfOAZJAnZ2H8Ju4aBzFZkBGXUqFs9V0yxw==
dependencies:
chalk "^1.1.3"
fancy-log "^1.3.2"
plugin-error "^0.1.2"
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
......
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