Browse Source

clean

master
blobt 4 years ago
parent
commit
b3d5a8c2fc
  1. 10
      .babelrc
  2. 0
      app/js/class/test.js
  3. 16
      app/js/index.js
  4. 0
      app/views/error.ejs
  5. 14
      app/views/index.ejs
  6. 3
      gulpfile.babel.js
  7. 7815
      npm-shrinkwrap.json
  8. 46
      package.json
  9. 41
      server/app.js
  10. 90
      server/bin/www
  11. 16
      server/package.json
  12. 21
      server/public/js/cp.min.js
  13. 51164
      server/public/js/index.js
  14. 9
      server/routes/index.js
  15. 9
      server/routes/users.js
  16. 0
      server/views/error.ejs
  17. 14
      server/views/index.ejs
  18. 11
      tasks/browser.js
  19. 4
      tasks/build.js
  20. 7
      tasks/clean.js
  21. 10
      tasks/css.js
  22. 2
      tasks/default.js
  23. 10
      tasks/pages.js
  24. 43
      tasks/scripts.js
  25. 19
      tasks/server.js
  26. 27
      tasks/util/args.js

10
.babelrc

@ -1,7 +1,5 @@
{
"presets": ["es2015"],
"retainLines": true,
"ignore": [
"node_modules"
]
}
"presets": [
"es2015"
]
}

0
app/js/class/test.js

16
app/js/index.js

@ -1,16 +0,0 @@
import * as THREE from 'three';
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor(0xb9d3ff, 1); //设置背景颜色
document.body.appendChild( renderer.domElement );
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set( 0, 0, 100 );
camera.lookAt( 0, 0, 0 );
var scene = new THREE.Scene();
renderer.render( scene, camera );

0
app/views/error.ejs

14
app/views/index.ejs

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<script src="/js/index.js" charset="utf-8"></script>
</body>
</html>

3
gulpfile.babel.js

@ -1,3 +0,0 @@
import requireDir from 'require-dir';
requireDir('./tasks');

7815
npm-shrinkwrap.json
File diff suppressed because it is too large
View File

46
package.json

@ -1,46 +0,0 @@
{
"name": "es6",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"connect-livereload": "^0.6.1",
"cookie-parser": "^1.4.5",
"del": "^2.2.2",
"ejs": "^3.1.5",
"express": "^4.17.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-if": "^2.0.2",
"gulp-live-server": "0.0.31",
"gulp-livereload": "^3.8.1",
"gulp-plumber": "^1.2.1",
"gulp-rename": "^1.4.0",
"gulp-sequence": "^0.4.6",
"gulp-uglify": "^2.1.2",
"gulp-util": "^3.0.8",
"mockjs": "^1.1.0",
"morgan": "^1.10.0",
"require-dir": "^0.3.2",
"serve-favicon": "^2.5.0",
"three": "^0.120.0",
"vinyl-named": "^1.1.0",
"webpack": "^2.7.0",
"webpack-stream": "^3.2.0",
"yargs": "^7.1.1"
},
"dependencies": {
"graceful-fs": "^4.2.4"
}
}

41
server/app.js

@ -1,41 +0,0 @@
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(require('connect-livereload')());
app.use('/', indexRouter);
app.use('/users', usersRouter);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;

90
server/bin/www

@ -1,90 +0,0 @@
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('server:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}

16
server/package.json

@ -1,16 +0,0 @@
{
"name": "server",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"ejs": "~2.6.1",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"morgan": "~1.9.1"
}
}

21
server/public/js/cp.min.js
File diff suppressed because it is too large
View File

51164
server/public/js/index.js
File diff suppressed because it is too large
View File

9
server/routes/index.js

@ -1,9 +0,0 @@
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;

9
server/routes/users.js

@ -1,9 +0,0 @@
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
module.exports = router;

0
server/views/error.ejs

14
server/views/index.ejs

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<script src="/js/index.js" charset="utf-8"></script>
</body>
</html>

11
tasks/browser.js

@ -1,11 +0,0 @@
import gulp from 'gulp';
import gulpif from 'gulp-if';
import gutil from 'gulp-util';
import args from './util/args';
gulp.task('browser', (cb)=>{
if(!args.watch) return cb();
gulp.watch('app/**/*.js', ['scripts']);
gulp.watch('app/**/*.ejs', ['pages']);
gulp.watch('app/**/*.css', ['css']);
})

4
tasks/build.js

@ -1,4 +0,0 @@
import gulp from 'gulp';
import gulpSequence from 'gulp-sequence';
gulp.task('build', gulpSequence('clean', 'css', 'pages', 'scripts', ['browser', 'server']));

7
tasks/clean.js

@ -1,7 +0,0 @@
import gulp from 'gulp';
import del from 'del';
import args from './util/args';
gulp.task('clean', ()=>{
return del(['server/public', 'server/views']);
})

10
tasks/css.js

@ -1,10 +0,0 @@
import gulp from 'gulp';
import gulpif from 'gulp-if';
import livereload from 'gulp-livereload';
import args from './util/args';
gulp.task('css',()=>{
return gulp.src('app/**/*.css')
.pipe(gulp.dest('server/public'))
.pipe(gulpif(args.watch, livereload()))
})

2
tasks/default.js

@ -1,2 +0,0 @@
import gulp from 'gulp';
gulp.task('default', ['build']);

10
tasks/pages.js

@ -1,10 +0,0 @@
import gulp from 'gulp';
import gulpif from 'gulp-if';
import livereload from 'gulp-livereload';
import args from './util/args'
gulp.task('pages',()=>{
return gulp.src('app/**/*.ejs')
.pipe(gulp.dest('server'))
.pipe(gulpif(args.watch, livereload()))
})

43
tasks/scripts.js

@ -1,43 +0,0 @@
import gulp from 'gulp';
import gulpif from 'gulp-if';
import concat from 'gulp-concat';
import webpack from 'webpack';
import gulpWebpack from 'webpack-stream';
import named from 'vinyl-named';
import livereload from 'gulp-livereload';
import plumber from 'gulp-plumber';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import {log,colors} from 'gulp-util';
import args from './util/args';
gulp.task('scripts',()=>{
return gulp.src(['app/js/index.js'])
.pipe(plumber({
errorHandle:function(){
}
}))
.pipe(named())
.pipe(gulpWebpack({
module:{
loaders:[{
test:/\.js$/,
loader:'babel',
query: {compact: false}
}]
}
}),null,(err,stats)=>{
log(`Finished '${colors.cyan('scripts')}'`,stats.toString({
chunks:false
}))
})
.pipe(gulp.dest('server/public/js'))
.pipe(rename({
basename:'cp',
extname:'.min.js'
}))
.pipe(uglify({compress:{properties:false},output:{'quote_keys':true}}))
.pipe(gulp.dest('server/public/js'))
.pipe(gulpif(args.watch,livereload()))
})

19
tasks/server.js

@ -1,19 +0,0 @@
import gulp from 'gulp';
import gulpif from 'gulp-if';
import liveserver from 'gulp-live-server';
import args from './util/args';
gulp.task('server',(cb)=>{
if(!args.watch) return cb();
var server = liveserver.new(['--harmony','server/bin/www']);
server.start();
gulp.watch(['server/public/**/*.js','server/views/**/*.ejs'],function(file){
server.notify.apply(server,[file]);
})
gulp.watch(['server/routes/**/*.js','server/app.js'],function(){
server.start.bind(server)()
});
})

27
tasks/util/args.js

@ -1,27 +0,0 @@
import yargs from 'yargs';
const args = yargs
.option('production', {
boolean: true,
default: false,
description: 'min all script'
})
.option('watch', {
boolean: true,
default: false,
description: 'watch all script'
})
.option('verbose', {
boolean: true,
default: false,
description: 'log'
})
.option('sourcemaps', {
description: 'force to create the sourcemaps'
})
.option('port', {
string: true,
default: 8080,
description: 'server port'
})
.argv
export default args;
Loading…
Cancel
Save