This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support new server-side build system
- Loading branch information
Showing
8 changed files
with
147 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
**/node_modules | ||
player/**/*.js | ||
server/**/*.js | ||
|
||
public/index.js | ||
public/plugins.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
const gulp = require("gulp"); | ||
|
||
// TypeScript | ||
const ts = require("gulp-typescript"); | ||
const tsProject = ts.createProject("./tsconfig.json"); | ||
const tslint = require("gulp-tslint"); | ||
|
||
gulp.task("typescript", function() { | ||
let failed = false; | ||
const tsResult = tsProject.src() | ||
.pipe(tslint()) | ||
.pipe(tslint.report("prose", { emitError: true })) | ||
.on("error", (err) => { throw err; }) | ||
.pipe(ts(tsProject)) | ||
.on("error", () => { failed = true; }) | ||
.on("end", () => { if (failed) throw new Error("There were TypeScript errors."); }); | ||
return tsResult.js.pipe(gulp.dest("./")); | ||
}); | ||
|
||
// All | ||
gulp.task("default", [ "typescript" ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../../../SupCore/SupCore.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as fs from "fs"; | ||
import * as async from "async"; | ||
|
||
interface ServerExportableAsset extends SupCore.Data.Base.Asset { | ||
serverExport: (folderPath: string, callback: (err: Error, writtenFiles: string[]) => void) => void; | ||
} | ||
|
||
SupCore.system.serverBuild = (server: ProjectServer, buildPath: string, callback: (err: string) => void) => { | ||
fs.mkdirSync(`${buildPath}/files`); | ||
|
||
const assetIdsToExport: string[] = []; | ||
server.data.entries.walk((entry: SupCore.Data.EntryNode, parent: SupCore.Data.EntryNode) => { | ||
if (entry.type != null && server.system.data.assetClasses[entry.type].prototype.serverExport != null) assetIdsToExport.push(entry.id); | ||
}); | ||
|
||
let files: string[] = []; | ||
|
||
async.each(assetIdsToExport, (assetId, cb) => { | ||
server.data.assets.acquire(assetId, null, (err: Error, asset: ServerExportableAsset) => { | ||
asset.serverExport(buildPath, (err, writtenFiles) => { | ||
server.data.assets.release(assetId, null); | ||
|
||
files = files.concat(writtenFiles); | ||
cb(); | ||
}); | ||
}); | ||
}, (err) => { | ||
if (err != null) { callback("Could not export all assets"); return; } | ||
|
||
const json = JSON.stringify(files, null, 2); | ||
fs.writeFile(`${buildPath}/files.json`, json, { encoding: "utf8" }, (err) => { | ||
if (err != null) { callback("Could not save files.json"); return; } | ||
|
||
callback(null); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"noImplicitAny": true | ||
} | ||
} |