diff --git a/.gitignore b/.gitignore index 5cfdf7b8..df41b5ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist build !.gitkeep *.tar.gz +bundle public/icons/* diff --git a/README.md b/README.md index 190c2874..7cf7a632 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,14 @@ This project was based on the [TruckSim-Telemetry-Demo](https://github.com/kniff All development are made under **Windows**. It's not operable under all Linux OS. -The view is optimized for a `5.5"` screen. To develop on you web browser, you can set phone view to `800px * 455px` +The view is optimized for a `5.5"` screen. To develop on you web browser, you can set phone view to `800px * 455px` + +## Requirements + +- OS: Windows 64Bits +- NodeJS: v10, v12 or v13 + +All current NodeJS version and LTS are supported. See the [NodeJS Release](https://nodejs.org/en/about/releases/) page to get more informations ## Quick use diff --git a/bin/scsSDKTelemetry.node10 b/bin/scsSDKTelemetry.node10 new file mode 100644 index 00000000..c83d7f1c Binary files /dev/null and b/bin/scsSDKTelemetry.node10 differ diff --git a/bin/scsSDKTelemetry.node12 b/bin/scsSDKTelemetry.node12 new file mode 100644 index 00000000..dfdbd100 Binary files /dev/null and b/bin/scsSDKTelemetry.node12 differ diff --git a/bin/scsSDKTelemetry.node13 b/bin/scsSDKTelemetry.node13 new file mode 100644 index 00000000..2f2e3840 Binary files /dev/null and b/bin/scsSDKTelemetry.node13 differ diff --git a/gulpfile.js b/gulpfile.js index 516116a6..8c5f6f77 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,13 +4,17 @@ const fs = require( 'fs-extra' ); const tar = require( 'gulp-tar' ); const gzip = require( 'gulp-gzip' ); const path = require( 'path' ); +const exec = require( 'child_process' ).execSync; + +const pkg = require( './package.json' ); +const pkgServer = require( './server/package.json' ); -const pkg = require( './package.json' ); // --------------------------------------------- // --- Variables // --------------------------------------------- + // --- Font icons const iconDist = 'resources/dist/'; const iconSvgs = 'resources/icons/svgs/*.svg'; @@ -25,29 +29,52 @@ const iconDistFontFiles = [ const iconDestFiles = 'public/icons/'; // --- Bundle -const filesToZip = [ +const filesToZip = [ './doc', './LICENSE', './package.json', './README.md', './screenshot.png' ]; -const bundleFileName = `${ pkg.name }_v${ pkg.version }`; -const archiveName = `${ bundleFileName }.tar`; -const archiveTemp = './build'; -const exeServerPathDest = `${ archiveTemp }/${ bundleFileName }`; -const destZip = './'; +const sdkTelemetryName = 'scsSDKTelemetry'; +const binPath = './bin/'; +const bundleFileName = `${ pkg.name }_v${ pkg.version }`; +const archiveTemp = './build'; +const destZip = './bundle'; +const nodeVersionTargets = pkgServer.pkg.targets; + // --------------------------------------------- -// --- Tasks +// --- Methods // --------------------------------------------- -const getExeServerTargetNode = () => { - const nodeVersion = process.version.match( /^v(\d{2})/ )[ 1 ]; - - return `node${ nodeVersion }-win`; + + +const getExeServerTargetNode = ( nodeTarget ) => { + return `${ nodeTarget }-win`; +}; + +const getExeServerPathDest = ( nodeTarget ) => { + return `${ archiveTemp }/${ nodeTarget }/${ bundleFileName }`; +}; + +const getTargetBuildPath = ( nodeTarget, filename ) => { + return path.resolve( archiveTemp, nodeTarget, filename ); +}; + +const getTargetBinPath = ( filename ) => { + return path.resolve( binPath, filename ); +}; + +const getArchiveName = ( nodeTarget ) => { + return `${ bundleFileName }_${ nodeTarget }.tar`; }; +// --------------------------------------------- +// --- Tasks +// --------------------------------------------- + + // --- Font icons gulp.task( 'build:font:init-folder', ( cb ) => { if ( !fs.existsSync( iconDist ) ) { @@ -72,30 +99,62 @@ gulp.task( 'bundle:clean', ( cb ) => { if ( fs.existsSync( archiveTemp ) ) { fs.removeSync( archiveTemp ); fs.mkdirSync( archiveTemp ); + + nodeVersionTargets.forEach( function ( currentTarget ) { + const nvtPath = path.resolve( archiveTemp, currentTarget ); + + fs.mkdirSync( nvtPath ); + } ); + console.log( `\t> Clean and empty created ${ archiveTemp }` ); } cb(); } ); gulp.task( 'bundle:copy', ( cb ) => { - filesToZip.forEach( function ( value ) { - const destPath = path.resolve( archiveTemp, value.replace( '*', '' ) ); - console.log( `\t> Coping ${ value } to ${ destPath }` ); + nodeVersionTargets.forEach( function ( currentTarget ) { + const scsTelemetryBinFileName = `${ sdkTelemetryName }.${ currentTarget }`; + const scsTelemetryBuildFileName = `${ sdkTelemetryName }.node`; - fs.copySync( value, destPath ); + filesToZip.forEach( function ( value ) { + const destPath = getTargetBuildPath( currentTarget, value ); + console.log( `\t> Coping ${ value } to ${ destPath }` ); + + fs.copySync( value, destPath ); + } ); + + fs.copySync( getTargetBinPath( scsTelemetryBinFileName ), + getTargetBuildPath( currentTarget, scsTelemetryBuildFileName ) ); } ); + cb(); } ); -gulp.task( 'bundle:server', run( `npx pkg ./server -t ${ getExeServerTargetNode() } -o ${ exeServerPathDest }` ) ); +gulp.task( 'bundle:server', ( cb ) => { + nodeVersionTargets.forEach( function ( currentTarget ) { + console.log( `\t> Generate *.exe file for ${ currentTarget }` ); + exec( `npx pkg ./server -t ${ getExeServerTargetNode( currentTarget ) } -o ${ getExeServerPathDest( + currentTarget ) }` ); + } ); + + console.log( `\t> All *.exe was generated` ); + cb(); +} ); gulp.task( 'bundle:gzip', () => { - return gulp.src( archiveTemp + '/**' ) - .pipe( tar( archiveName ) ) - .pipe( gzip() ) - .pipe( gulp.dest( destZip ) ); + let g = null; + + nodeVersionTargets.forEach( function ( currentTarget ) { + g = gulp.src( getTargetBuildPath( currentTarget, './**' ) ) + .pipe( tar( getArchiveName( currentTarget ) ) ) + .pipe( gzip() ) + .pipe( gulp.dest( destZip ) ); + } ); + + return g; } ); // --- Build full package gulp.task( 'build', gulp.series( 'build:font', 'build:dashboard', 'build:server' ) ); gulp.task( 'bundle', gulp.series( 'bundle:clean', 'bundle:copy', 'bundle:server', 'bundle:gzip' ) ); +gulp.task( 'bAndB', gulp.series( 'build', 'bundle' ) ); diff --git a/package.json b/package.json index c485bbdc..d68fe793 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "homepage" : "https://jagfx.github.io/ets2-dashboard-skin/", "private" : false, "main" : "index.js", - "scripts" : { + "scripts" : { "server:build" : "cd server && npx gulp", "server:start" : "cd server && node ./dist/index.js", "dashboard:dev" : "vue-cli-service serve", @@ -28,7 +28,8 @@ "dashboard:start" : "http-server dist/", "font:build" : "npx gulp build:font", "build" : "npx gulp build", - "bundle" : "npx gulp bundle" + "bundle" : "npx gulp bundle", + "bAndB" : "npx gulp bAndB" }, "dependencies" : { "animate.css" : "^3.7.2", diff --git a/server/index.js b/server/index.js index d1e1c517..f71b799f 100644 --- a/server/index.js +++ b/server/index.js @@ -1,8 +1,9 @@ -import path from 'path'; -import http from 'http'; import express from 'express'; +import http from 'http'; +import path from 'path'; import socketio from 'socket.io'; import truckSimTelemetry from 'trucksim-telemetry'; +import pkgDash from '../package.json'; const app = express(); const server = http.createServer( app ); @@ -74,5 +75,5 @@ io.on( 'connection', function ( socket ) { } ); server.listen( 3000, function () { - console.log( 'TruckSim-Telemetry Demo is running at http://localhost:3000/' ); + console.log( `${ pkgDash.description } is running at http://localhost:3000/` ); } ); diff --git a/server/package-lock.json b/server/package-lock.json index e44aff73..a2295a3f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,6 +1,6 @@ { "name": "ets2-dashboard-skin-server", - "version": "0.1.1", + "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/server/package.json b/server/package.json index 7d2b050e..df806a6a 100644 --- a/server/package.json +++ b/server/package.json @@ -31,6 +31,8 @@ "../dist/" ], "targets" : [ + "node10", + "node12", "node13" ] }