rokojori-godot/rokojori-cpp-generator/builds/create-output.js

77 lines
3.6 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const RJLog_1 = require("./library/RJLog");
const { argv } = require("process");
const path = require("path");
const fs = require("node:fs/promises");
const { exists } = require("./library.js");
let targetDirectory = "outputs";
let godotName = "godot-4.3-dev-rokojori";
let platform = "argv[ 2 ]";
let godotPlatformName = godotName + "-" + "argv[ 2 ]";
let platformTargetDirectory = path.join(targetDirectory, godotPlatformName);
function main() {
return __awaiter(this, void 0, void 0, function* () {
if (argv.length !== 3) {
let platforms = ["windows"];
console.error("Platform missing in the command. Add one of these to the command line:", platforms.join(", "));
return;
}
platform = argv[2];
godotPlatformName = godotName + "-" + argv[2];
platformTargetDirectory = path.join(targetDirectory, godotPlatformName);
RJLog_1.RJLog.log("Creating output");
yield deleteOldDirectory();
yield createDirectory();
RJLog_1.RJLog.log("Output done");
});
}
function deleteOldDirectory() {
return __awaiter(this, void 0, void 0, function* () {
let directoryExists = yield exists(platformTargetDirectory);
RJLog_1.RJLog.log("checking if old directory exists", directoryExists);
if (directoryExists) {
RJLog_1.RJLog.log(`deleting previous directory: "${platformTargetDirectory}"`);
yield fs.rm(platformTargetDirectory, { recursive: true });
}
return Promise.resolve();
});
}
function createDirectory() {
return __awaiter(this, void 0, void 0, function* () {
RJLog_1.RJLog.log(`creating directory: "${platformTargetDirectory}"`);
yield fs.mkdir(platformTargetDirectory, { recursive: true });
let godotFrom = "godot/bin";
let godotTo = path.join(platformTargetDirectory, "godot");
RJLog_1.RJLog.log(`copying godot: "${godotFrom}" >> "${godotTo}"`);
yield fs.cp(godotFrom, godotTo, { recursive: true });
let npFrom = "godot-rj-nuget-package";
let npTo = path.join(platformTargetDirectory, npFrom);
RJLog_1.RJLog.log(`copying nupkg: "${npFrom}" >> "${npTo}"`);
yield fs.cp(npFrom, npTo, { recursive: true });
let installerFiles = {
"windows": [
"install-godot-windows.bat",
"install-godot-windows-readme.txt"
]
};
let installers = installerFiles[platform];
for (let installer of installers) {
let installFrom = "install-scripts/" + installer;
let installTo = path.join(platformTargetDirectory, installer);
RJLog_1.RJLog.log(`copying installer: "${installFrom}" >> "${installTo}"`);
yield fs.cp(installFrom, installTo, { recursive: true });
}
});
}
main();
//# sourceMappingURL=create-output.js.map