From 29641e630969db56e0b1ca4f3bb9aa71a35a9e2d Mon Sep 17 00:00:00 2001 From: stormchaser2018 Date: Tue, 20 Nov 2018 16:55:28 -0600 Subject: [PATCH 1/2] feat: added the CLI command to use Igor to clear remote client # Conflicts: # src/rubber.ts --- .vscode/.gitignore | 2 ++ src/cli.ts | 27 ++++++++++++++++----------- src/rubber.ts | 10 ++++++++-- 3 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 .vscode/.gitignore diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 0000000..01d5798 --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1,2 @@ +/tasks.json +/settings.json diff --git a/src/cli.ts b/src/cli.ts index 3f7de9c..a3e41c1 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -36,6 +36,7 @@ const options = cli.parse({ config: ["c", "Sets the configuration", "string"], version: ["v", "Display the current version"], clear: ["", "Clears cache for project and exits."], + "clear_remote": ["","Clears the remote client cache."], "gms-dir":["","Alternative GMS installation directory","path"], "export-platform":["p","Export platform","string"], "device-config-dir":["","Target device config file directory", "path"], @@ -79,14 +80,6 @@ cli.main(async (args, options) => { cli.fatal("Project invalid, or in a newer format. Exiting"); } - // Clear cache option - if(options.clear) { - rubber.clearCache(path).then(() => { - cli.info("Cleared Project Cache."); - }); - return; - } - // We have a probably valid project. Time to pass it to rubber let buildType: "test" | "zip" | "installer" = "test"; if (options.zip && options.installer) { @@ -127,8 +120,8 @@ cli.main(async (args, options) => { theRuntime = options["runtime"]; } - // Use the api to compile the project. - const build = rubber.compile({ + // + let rubberOptions = { projectPath: path, build: buildType, outputPath: args[1] || "", @@ -141,7 +134,19 @@ cli.main(async (args, options) => { targetDeviceName, theRuntime, ea: options.ea - }); + } + + // Clear build machine's cache + if(options.clear) { + rubber.clearCache(path).then(() => { + cli.info("Cleared Project Cache."); + }); + return; + } + + // Use the api to compile the project or clear the remote client cache. + const build = options["clear_remote"] ? rubber.clearCacheRemote(rubberOptions) : rubber.compile(rubberOptions,false); + build.on("compileStatus", (data:string) => { // Errors will be marked in red if(data.toLowerCase().startsWith("error")) { diff --git a/src/rubber.ts b/src/rubber.ts index a5379a4..b98a4a2 100644 --- a/src/rubber.ts +++ b/src/rubber.ts @@ -68,7 +68,8 @@ export interface IRubberOptions { * @param projectFile Path to the .yyp project * @param options Object containing build information. */ -export function compile(options: IRubberOptions) { + +export function compile(options: IRubberOptions, clearRemoteCache: boolean) { const emitter = new EventEmitter() as RubberEventEmitter; // we dont need the overhead of a sub class const projectFile = resolve(options.projectPath); const platform = options.platform; @@ -506,7 +507,7 @@ export function compile(options: IRubberOptions) { emitter.emit("compileStatus", "Running IGOR\n"); const exportType = options.build == "test" ? "Run" : (options.build === "zip" ? defaultPackageKey : "PackageNsis") - const igorArgs = ["-options=" + join(buildTempPath, "build.bff"), "--", component, exportType]; + const igorArgs = ["-options=" + join(buildTempPath, "build.bff"), "--", component, clearRemoteCache ? "Clean" : exportType]; const igor = spawn(join(runtimeLocation, "bin", "Igor.exe"), igorArgs); // !!! #8 todo: store errors here, emit at end. @@ -586,3 +587,8 @@ export async function clearCache(projectPath: string) { // delete the folder await fse.remove(join(tempFolder, "gamemaker-rubber", guid)); } + +/** Use Igor's Clean function to clear remote client's cache */ +export function clearCacheRemote(options: IRubberOptions){ + return compile(options, true); +} \ No newline at end of file From cce69a89d32a679fcf16cf719532564d54fbeb3e Mon Sep 17 00:00:00 2001 From: Dave <24465214+imdaveead@users.noreply.github.com> Date: Thu, 22 Nov 2018 13:54:40 -0500 Subject: [PATCH 2/2] add a default value to clearRemoteCache i think it would be overall better to have that as part of the options object, but i feel lazy today to rework the other work done --- src/rubber.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rubber.ts b/src/rubber.ts index b98a4a2..b8ba954 100644 --- a/src/rubber.ts +++ b/src/rubber.ts @@ -68,8 +68,7 @@ export interface IRubberOptions { * @param projectFile Path to the .yyp project * @param options Object containing build information. */ - -export function compile(options: IRubberOptions, clearRemoteCache: boolean) { +export function compile(options: IRubberOptions, clearRemoteCache: boolean = false) { const emitter = new EventEmitter() as RubberEventEmitter; // we dont need the overhead of a sub class const projectFile = resolve(options.projectPath); const platform = options.platform; @@ -591,4 +590,4 @@ export async function clearCache(projectPath: string) { /** Use Igor's Clean function to clear remote client's cache */ export function clearCacheRemote(options: IRubberOptions){ return compile(options, true); -} \ No newline at end of file +}