From 0537c5a914a8bf26c6d353a62d0fe387218300ac Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 19:54:59 +0100 Subject: [PATCH 01/30] Added an local rebuilding. --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1806af8..2288073 100644 --- a/index.js +++ b/index.js @@ -98,8 +98,6 @@ async function postCode() { const login_arguments = { token: token, - username: username, - password: password, protocol: protocol, hostname: hostname, port: port, @@ -116,8 +114,12 @@ async function postCode() { core.error(errorMessage); return; } - - const api = new ScreepsAPI(login_arguments); + let api; + if (token) { + api = new ScreepsAPI(login_arguments); + } else { + api = new ScreepsAPI(username, password, login_arguments); + } const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); } -- 2.49.1 From bc567661105bf67d369e34ab1af4284f85ed6f04 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 19:56:56 +0100 Subject: [PATCH 02/30] Added a bit more logging. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 2288073..8e1b967 100644 --- a/index.js +++ b/index.js @@ -118,6 +118,7 @@ async function postCode() { if (token) { api = new ScreepsAPI(login_arguments); } else { + core.info(`Logging into as usewr ${username}`); api = new ScreepsAPI(username, password, login_arguments); } const response = await api.code.set(branch, files_to_push); -- 2.49.1 From 9be17fd1a040c874aacbe2690bacc224975f9885 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 19:59:04 +0100 Subject: [PATCH 03/30] Reworked the username. --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8e1b967..61a20f8 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,8 @@ async function postCode() { api = new ScreepsAPI(login_arguments); } else { core.info(`Logging into as usewr ${username}`); - api = new ScreepsAPI(username, password, login_arguments); + api = new ScreepsAPI(); + api.auth(username, password, login_arguments); } const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); -- 2.49.1 From 7f5df4a59e141d7110ad02754e8cda1625e4feaa Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:10:35 +0100 Subject: [PATCH 04/30] Reworked everything a bit. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 61a20f8..3e3fa40 100644 --- a/index.js +++ b/index.js @@ -119,8 +119,8 @@ async function postCode() { api = new ScreepsAPI(login_arguments); } else { core.info(`Logging into as usewr ${username}`); - api = new ScreepsAPI(); - api.auth(username, password, login_arguments); + api = new ScreepsAPI(login_arguments); + api.auth(username, password); } const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); -- 2.49.1 From a312781dc77886b41f30e1ac3d37f1ea784fe316 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:13:10 +0100 Subject: [PATCH 05/30] Reworked a bit of logging. --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3e3fa40..b108bd1 100644 --- a/index.js +++ b/index.js @@ -90,6 +90,7 @@ async function postCode() { const files_to_push = await readFilesIntoDict(pattern, prefix); + core.info(`Trying to upload the following files to ${branch}:`); Object.keys(files_to_push).forEach((key) => { core.info(`Key: ${key}`); }); @@ -104,7 +105,8 @@ async function postCode() { path: path, }; - core.info(`Trying to upload the following files to ${branch}:`); + core.info("login_arguments:"); + core.info(JSON.stringify(login_arguments, null, 2)); Object.keys(login_arguments).forEach((key) => { core.info(`Key: ${key}`); }); -- 2.49.1 From ddd15b40637fd5194a49fc3b7f21577c5824e068 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:21:47 +0100 Subject: [PATCH 06/30] Added an await token to the autorization --- index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index b108bd1..e526b20 100644 --- a/index.js +++ b/index.js @@ -95,8 +95,6 @@ async function postCode() { core.info(`Key: ${key}`); }); - core.info(files_to_push); - const login_arguments = { token: token, protocol: protocol, @@ -107,9 +105,6 @@ async function postCode() { core.info("login_arguments:"); core.info(JSON.stringify(login_arguments, null, 2)); - Object.keys(login_arguments).forEach((key) => { - core.info(`Key: ${key}`); - }); const errorMessage = validateAuthentication(token, username, password); if (errorMessage) { @@ -120,9 +115,10 @@ async function postCode() { if (token) { api = new ScreepsAPI(login_arguments); } else { - core.info(`Logging into as usewr ${username}`); + core.info(`Logging into as user ${username}`); api = new ScreepsAPI(login_arguments); - api.auth(username, password); + await api.auth(username, password); + core.info("Authorized!"); } const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); -- 2.49.1 From dd929af281929892a1254b9bd2cfb811d9eb7196 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:50:28 +0100 Subject: [PATCH 07/30] Reworkeed the function to use Promice resolve --- index.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e526b20..041f5e0 100644 --- a/index.js +++ b/index.js @@ -114,14 +114,26 @@ async function postCode() { let api; if (token) { api = new ScreepsAPI(login_arguments); + const response = await api.code.set(branch, files_to_push); + core.info(JSON.stringify(response, null, 2)); } else { core.info(`Logging into as user ${username}`); - api = new ScreepsAPI(login_arguments); - await api.auth(username, password); + const response = Promise.resolve() + .then(() => api.auth(auth.email, auth.password)) + .then(() => api.socket.connect()) + .then(() => { + return api.code.set(branch, code); // Set the code on the specified branch + }) + .then(() => { + console.log("Code set successfully"); + // Additional actions after setting the code, if necessary + }) + .catch((err) => { + console.error("Error:", err); + }); core.info("Authorized!"); + core.info(JSON.stringify(response, null, 2)); } - const response = await api.code.set(branch, files_to_push); - core.info(JSON.stringify(response, null, 2)); } postCode(); -- 2.49.1 From 368ba865599863facfa7a41b57ece3f462d6f823 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:52:00 +0100 Subject: [PATCH 08/30] Reworked the login --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 041f5e0..c2926f8 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,7 @@ async function postCode() { } else { core.info(`Logging into as user ${username}`); const response = Promise.resolve() - .then(() => api.auth(auth.email, auth.password)) + .then(() => api.auth("philipp@horstenkamp.de", password)) .then(() => api.socket.connect()) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch -- 2.49.1 From 14f12188451b5c6f1c899207d87c1ba67d953ffe Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:56:15 +0100 Subject: [PATCH 09/30] Removed the auth step. --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c2926f8..40b3e45 100644 --- a/index.js +++ b/index.js @@ -101,6 +101,8 @@ async function postCode() { hostname: hostname, port: port, path: path, + username: username, + password: password, }; core.info("login_arguments:"); @@ -119,7 +121,7 @@ async function postCode() { } else { core.info(`Logging into as user ${username}`); const response = Promise.resolve() - .then(() => api.auth("philipp@horstenkamp.de", password)) + // .then(() => api.auth("philipp@horstenkamp.de", password)) .then(() => api.socket.connect()) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch -- 2.49.1 From c69726c6007179829c658b8486c06251429bae31 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:57:33 +0100 Subject: [PATCH 10/30] Reworked something --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 40b3e45..ff9a564 100644 --- a/index.js +++ b/index.js @@ -122,7 +122,6 @@ async function postCode() { core.info(`Logging into as user ${username}`); const response = Promise.resolve() // .then(() => api.auth("philipp@horstenkamp.de", password)) - .then(() => api.socket.connect()) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch }) -- 2.49.1 From dbd765cbdf1fe39d3ab523664ae7c16595ccd3bb Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 20:59:44 +0100 Subject: [PATCH 11/30] Reworked index. --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index ff9a564..3d403f9 100644 --- a/index.js +++ b/index.js @@ -113,9 +113,8 @@ async function postCode() { core.error(errorMessage); return; } - let api; + let api = new ScreepsAPI(login_arguments); if (token) { - api = new ScreepsAPI(login_arguments); const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); } else { -- 2.49.1 From d9aa117ac6473b35518e7512e2dae462f00c327a Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:01:42 +0100 Subject: [PATCH 12/30] Reworked everything. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3d403f9..e08eaa2 100644 --- a/index.js +++ b/index.js @@ -120,7 +120,7 @@ async function postCode() { } else { core.info(`Logging into as user ${username}`); const response = Promise.resolve() - // .then(() => api.auth("philipp@horstenkamp.de", password)) + .then(() => api.auth(username, password)) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch }) -- 2.49.1 From 8c4feac99a088ff68ff409c78c358997d565589d Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:05:09 +0100 Subject: [PATCH 13/30] Reworked index,js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index e08eaa2..c85c3a1 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,7 @@ async function postCode() { const token = core.getInput("token") || undefined; const username = core.getInput("username") || undefined; + core.info(username); const password = core.getInput("password") || undefined; const prefix = core.getInput("source-prefix"); const pattern = core.getInput("pattern") || "*.js"; -- 2.49.1 From a114309427ceb6ad4a7beec2792833441c7241a3 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:06:25 +0100 Subject: [PATCH 14/30] Added more testing. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c85c3a1..2ccea37 100644 --- a/index.js +++ b/index.js @@ -121,7 +121,7 @@ async function postCode() { } else { core.info(`Logging into as user ${username}`); const response = Promise.resolve() - .then(() => api.auth(username, password)) + .then(() => api.auth("NameVergessen", password)) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch }) -- 2.49.1 From 7b50736f648801f6e9005c62f314f6ec696f72d2 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:23:28 +0100 Subject: [PATCH 15/30] Reworked auth again! --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 2ccea37..0e0cb44 100644 --- a/index.js +++ b/index.js @@ -83,7 +83,6 @@ async function postCode() { const token = core.getInput("token") || undefined; const username = core.getInput("username") || undefined; - core.info(username); const password = core.getInput("password") || undefined; const prefix = core.getInput("source-prefix"); const pattern = core.getInput("pattern") || "*.js"; @@ -102,7 +101,7 @@ async function postCode() { hostname: hostname, port: port, path: path, - username: username, + username: "NameVergessen", password: password, }; @@ -121,7 +120,7 @@ async function postCode() { } else { core.info(`Logging into as user ${username}`); const response = Promise.resolve() - .then(() => api.auth("NameVergessen", password)) + .then(() => api.auth(username, password)) .then(() => { return api.code.set(branch, code); // Set the code on the specified branch }) -- 2.49.1 From b0725e82193c1bab03fccad6994ec5622908a5c4 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:26:08 +0100 Subject: [PATCH 16/30] Added jshint as a linter. --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83cdbd3..83e1796 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,3 +49,8 @@ repos: hooks: - id: prettier types_or: [css, javascript] + +- repo: https://github.com/pre-commit/mirrors-jshint + rev: v2.13.6 # Use the sha / tag you want to point at + hooks: + - id: jshint -- 2.49.1 From ad5a6efa149e1fdae91b85aeb93c97684ab627f3 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:30:27 +0100 Subject: [PATCH 17/30] Commented out a log. --- .pre-commit-config.yaml | 5 ----- index.js | 40 ++++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83e1796..83cdbd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,8 +49,3 @@ repos: hooks: - id: prettier types_or: [css, javascript] - -- repo: https://github.com/pre-commit/mirrors-jshint - rev: v2.13.6 # Use the sha / tag you want to point at - hooks: - - id: jshint diff --git a/index.js b/index.js index 0e0cb44..1e82cc1 100644 --- a/index.js +++ b/index.js @@ -114,26 +114,26 @@ async function postCode() { return; } let api = new ScreepsAPI(login_arguments); - if (token) { - const response = await api.code.set(branch, files_to_push); - core.info(JSON.stringify(response, null, 2)); - } else { - core.info(`Logging into as user ${username}`); - const response = Promise.resolve() - .then(() => api.auth(username, password)) - .then(() => { - return api.code.set(branch, code); // Set the code on the specified branch - }) - .then(() => { - console.log("Code set successfully"); - // Additional actions after setting the code, if necessary - }) - .catch((err) => { - console.error("Error:", err); - }); - core.info("Authorized!"); - core.info(JSON.stringify(response, null, 2)); - } + // if (token) { + const response = await api.code.set(branch, files_to_push); + core.info(JSON.stringify(response, null, 2)); + //} else { + //core.info(`Logging into as user ${username}`); + //const response = Promise.resolve() + // .then(() => api.auth(username, password)) + // .then(() => { + // return api.code.set(branch, code); // Set the code on the specified branch + // }) + // .then(() => { + // console.log("Code set successfully"); + // // Additional actions after setting the code, if necessary + // }) + // .catch((err) => { + // console.error("Error:", err); + // }); + // core.info("Authorized!"); + // core.info(JSON.stringify(response, null, 2)); + // } } postCode(); -- 2.49.1 From 2e271692b0ba902b82e6799a421b3e87bac77868 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:34:26 +0100 Subject: [PATCH 18/30] Tried the logout again. --- index.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index 1e82cc1..1f14433 100644 --- a/index.js +++ b/index.js @@ -114,26 +114,26 @@ async function postCode() { return; } let api = new ScreepsAPI(login_arguments); - // if (token) { - const response = await api.code.set(branch, files_to_push); - core.info(JSON.stringify(response, null, 2)); - //} else { - //core.info(`Logging into as user ${username}`); - //const response = Promise.resolve() - // .then(() => api.auth(username, password)) - // .then(() => { - // return api.code.set(branch, code); // Set the code on the specified branch - // }) - // .then(() => { - // console.log("Code set successfully"); - // // Additional actions after setting the code, if necessary - // }) - // .catch((err) => { - // console.error("Error:", err); - // }); - // core.info("Authorized!"); - // core.info(JSON.stringify(response, null, 2)); - // } + if (token) { + const response = await api.code.set(branch, files_to_push); + core.info(JSON.stringify(response, null, 2)); + } else { + core.info(`Logging into as user ${username}`); + const response = Promise.resolve() + .then(() => api.auth(username, password, login_arguments)) + .then(() => { + return api.code.set(branch, code); // Set the code on the specified branch + }) + .then(() => { + console.log("Code set successfully"); + // Additional actions after setting the code, if necessary + }) + .catch((err) => { + console.error("Error:", err); + }); + core.info("Authorized!"); + core.info(JSON.stringify(response, null, 2)); + } } postCode(); -- 2.49.1 From 7933a62f3a5859eb84aaae1520b1edd219c3c6ef Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:48:39 +0100 Subject: [PATCH 19/30] Update the auth function --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1f14433..dd49566 100644 --- a/index.js +++ b/index.js @@ -119,10 +119,12 @@ async function postCode() { core.info(JSON.stringify(response, null, 2)); } else { core.info(`Logging into as user ${username}`); + // await api.auth(username, password, login_arguments)); + // await api.auth(username, password, login_arguments)); const response = Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - return api.code.set(branch, code); // Set the code on the specified branch + return api.code.set(branch, files_to_push); }) .then(() => { console.log("Code set successfully"); -- 2.49.1 From 7c75b9d0002790d8fb4c602e73424f8739c1212f Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:50:25 +0100 Subject: [PATCH 20/30] Reworked a message. --- index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/index.js b/index.js index dd49566..2502321 100644 --- a/index.js +++ b/index.js @@ -119,16 +119,13 @@ async function postCode() { core.info(JSON.stringify(response, null, 2)); } else { core.info(`Logging into as user ${username}`); - // await api.auth(username, password, login_arguments)); - // await api.auth(username, password, login_arguments)); const response = Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { return api.code.set(branch, files_to_push); }) .then(() => { - console.log("Code set successfully"); - // Additional actions after setting the code, if necessary + console.log(`Code set successfully to ${branch}`); }) .catch((err) => { console.error("Error:", err); -- 2.49.1 From 3eeeb73e0efede092d9ccde2e67d35dacd9a9b10 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:54:05 +0100 Subject: [PATCH 21/30] Reworked the login arguments again. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2502321..0295f41 100644 --- a/index.js +++ b/index.js @@ -96,13 +96,13 @@ async function postCode() { }); const login_arguments = { + username: username, + password: password, token: token, protocol: protocol, hostname: hostname, port: port, path: path, - username: "NameVergessen", - password: password, }; core.info("login_arguments:"); -- 2.49.1 From 2b9a04a1360368df2e599cd3083c7331706d1414 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:54:46 +0100 Subject: [PATCH 22/30] Changed the dict order again. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 0295f41..15362b8 100644 --- a/index.js +++ b/index.js @@ -96,9 +96,9 @@ async function postCode() { }); const login_arguments = { + token: token, username: username, password: password, - token: token, protocol: protocol, hostname: hostname, port: port, -- 2.49.1 From 8eebf7bb27f82afbab0a44b6589aa0817b4f259a Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:58:22 +0100 Subject: [PATCH 23/30] Added an awit token --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 15362b8..bc61ea8 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,7 @@ async function postCode() { core.info(JSON.stringify(response, null, 2)); } else { core.info(`Logging into as user ${username}`); - const response = Promise.resolve() + const response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { return api.code.set(branch, files_to_push); @@ -131,7 +131,6 @@ async function postCode() { console.error("Error:", err); }); core.info("Authorized!"); - core.info(JSON.stringify(response, null, 2)); } } -- 2.49.1 From af0e213e80bb08d0403dc23fcb48101dc674d388 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 21:59:11 +0100 Subject: [PATCH 24/30] Reworked stringify --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index bc61ea8..f162441 100644 --- a/index.js +++ b/index.js @@ -130,6 +130,7 @@ async function postCode() { .catch((err) => { console.error("Error:", err); }); + core.info(JSON.stringify(response, null, 2)); core.info("Authorized!"); } } -- 2.49.1 From 804a96901a00d3976a8050a8bdca5c74030aea6d Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:04:51 +0100 Subject: [PATCH 25/30] Reworked the response parsing. --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f162441..fa38cd4 100644 --- a/index.js +++ b/index.js @@ -119,10 +119,10 @@ async function postCode() { core.info(JSON.stringify(response, null, 2)); } else { core.info(`Logging into as user ${username}`); - const response = await Promise.resolve() + response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - return api.code.set(branch, files_to_push); + core.info(JSON.stringify(api.code.set(branch, files_to_push), null, 2)); }) .then(() => { console.log(`Code set successfully to ${branch}`); @@ -130,7 +130,6 @@ async function postCode() { .catch((err) => { console.error("Error:", err); }); - core.info(JSON.stringify(response, null, 2)); core.info("Authorized!"); } } -- 2.49.1 From 6b56c9c93706953bfa288b64b0a257afdc889f8a Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:08:42 +0100 Subject: [PATCH 26/30] Reworked the response again. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fa38cd4..40d0a52 100644 --- a/index.js +++ b/index.js @@ -118,11 +118,12 @@ async function postCode() { const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); } else { + let response; core.info(`Logging into as user ${username}`); response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - core.info(JSON.stringify(api.code.set(branch, files_to_push), null, 2)); + response = api.code.set(branch, files_to_push); }) .then(() => { console.log(`Code set successfully to ${branch}`); @@ -130,7 +131,7 @@ async function postCode() { .catch((err) => { console.error("Error:", err); }); - core.info("Authorized!"); + core.info(JSON.stringify(response)); } } -- 2.49.1 From 5fc053cd7605ec0463550205d6a7f868a9d72227 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:14:09 +0100 Subject: [PATCH 27/30] Changed a docstring and added an await. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 40d0a52..9eaadfb 100644 --- a/index.js +++ b/index.js @@ -117,9 +117,10 @@ async function postCode() { if (token) { const response = await api.code.set(branch, files_to_push); core.info(JSON.stringify(response, null, 2)); + console.log(`Code set successfully to ${branch}`); } else { let response; - core.info(`Logging into as user ${username}`); + core.info(`Logging in as user ${username}`); response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { @@ -131,7 +132,7 @@ async function postCode() { .catch((err) => { console.error("Error:", err); }); - core.info(JSON.stringify(response)); + core.info(JSON.stringify(await response)); } } -- 2.49.1 From d241d51744155e8a791612154311a0ebcaddee73 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:19:27 +0100 Subject: [PATCH 28/30] Reworked the result. --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9eaadfb..e60b4cd 100644 --- a/index.js +++ b/index.js @@ -124,15 +124,16 @@ async function postCode() { response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - response = api.code.set(branch, files_to_push); + api.code.set(branch, files_to_push); }) - .then(() => { + .then((result) => { + response = result; console.log(`Code set successfully to ${branch}`); }) .catch((err) => { console.error("Error:", err); }); - core.info(JSON.stringify(await response)); + core.info(JSON.stringify(response)); } } -- 2.49.1 From 1b1254c57aa766926896389275afec2ed3319e35 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:20:36 +0100 Subject: [PATCH 29/30] Reworked the response again --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e60b4cd..52937ca 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,7 @@ async function postCode() { response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - api.code.set(branch, files_to_push); + return api.code.set(branch, files_to_push); }) .then((result) => { response = result; -- 2.49.1 From c0e41f1845ff40dc4b4dd2a6066127c821df04e4 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Sun, 26 Nov 2023 22:22:54 +0100 Subject: [PATCH 30/30] Removed not working logs. --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 52937ca..164cc3b 100644 --- a/index.js +++ b/index.js @@ -124,16 +124,14 @@ async function postCode() { response = await Promise.resolve() .then(() => api.auth(username, password, login_arguments)) .then(() => { - return api.code.set(branch, files_to_push); + api.code.set(branch, files_to_push); }) - .then((result) => { - response = result; + .then(() => { console.log(`Code set successfully to ${branch}`); }) .catch((err) => { console.error("Error:", err); }); - core.info(JSON.stringify(response)); } } -- 2.49.1