From 624d72a7c3f071bbfa0fd2e8df9f9ad57d4f3db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 15:12:21 +0200 Subject: [PATCH 1/6] fix issue with git clone when preparing meteor example --- tools/cli/commands.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index f55a9f3854..b47f5c5446 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -41,12 +41,6 @@ const runCommand = async (command) => { reject(error); return; } - if (stderr) { - if (stderr.includes("Cloning into")) console.log(green`${ stderr }`); - else console.log(red`stderr: ${ stderr }`); - reject(stderr); - return; - } resolve(stdout); }); }) @@ -1055,7 +1049,7 @@ main.registerCommand({ * @param {string} url */ const setupExampleByURL = async (url) => { - const [ok, err] = await bash`git -v`; + const [ok, err] = await bash`git --version`; if (err) throw new Error("git is not installed"); const isWindows = process.platform === "win32"; // Set GIT_TERMINAL_PROMPT=0 to disable prompting @@ -1063,7 +1057,8 @@ main.registerCommand({ ? `set GIT_TERMINAL_PROMPT=0 && git clone --progress ${url} ${appPath}` : `GIT_TERMINAL_PROMPT=0 git clone --progress ${url} ${appPath}`; const [okClone, errClone] = await bash`${gitCommand}`; - if (errClone && !errClone.message.includes("Cloning into")) { + const errorMessage = errClone && typeof errClone === "string" ? errClone : errClone?.message; + if (errorMessage && errorMessage.includes("Cloning into")) { throw new Error("error cloning skeleton"); } // remove .git folder from the example From 344dea1d5ea419035f30820fee0c139de609ecf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 15:16:22 +0200 Subject: [PATCH 2/6] fix git clone windows command --- tools/cli/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index b47f5c5446..39e6bc8e96 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -1054,7 +1054,7 @@ main.registerCommand({ const isWindows = process.platform === "win32"; // Set GIT_TERMINAL_PROMPT=0 to disable prompting const gitCommand = isWindows - ? `set GIT_TERMINAL_PROMPT=0 && git clone --progress ${url} ${appPath}` + ? `$env:GIT_TERMINAL_PROMPT=0; git clone --progress ${url} ${appPath}` : `GIT_TERMINAL_PROMPT=0 git clone --progress ${url} ${appPath}`; const [okClone, errClone] = await bash`${gitCommand}`; const errorMessage = errClone && typeof errClone === "string" ? errClone : errClone?.message; From 0fae99dc571e18908f04ca69c3a32210b8ba36e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 15:38:03 +0200 Subject: [PATCH 3/6] convert to proper os path --- tools/cli/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 39e6bc8e96..22b2f56772 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -1054,7 +1054,7 @@ main.registerCommand({ const isWindows = process.platform === "win32"; // Set GIT_TERMINAL_PROMPT=0 to disable prompting const gitCommand = isWindows - ? `$env:GIT_TERMINAL_PROMPT=0; git clone --progress ${url} ${appPath}` + ? `$env:GIT_TERMINAL_PROMPT=0; git clone --progress ${url} ${files.convertToOSPath(appPath)}` : `GIT_TERMINAL_PROMPT=0 git clone --progress ${url} ${appPath}`; const [okClone, errClone] = await bash`${gitCommand}`; const errorMessage = errClone && typeof errClone === "string" ? errClone : errClone?.message; From e0d44f34052e01d8c9d446c337606893c80430c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 15:57:43 +0200 Subject: [PATCH 4/6] set env variable as part of node to simplify cmd output --- tools/cli/commands.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 22b2f56772..12b82f99c0 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -1052,10 +1052,12 @@ main.registerCommand({ const [ok, err] = await bash`git --version`; if (err) throw new Error("git is not installed"); const isWindows = process.platform === "win32"; + + process.env.GIT_TERMINAL_PROMPT = 0; // Set GIT_TERMINAL_PROMPT=0 to disable prompting const gitCommand = isWindows - ? `$env:GIT_TERMINAL_PROMPT=0; git clone --progress ${url} ${files.convertToOSPath(appPath)}` - : `GIT_TERMINAL_PROMPT=0 git clone --progress ${url} ${appPath}`; + ? `git clone --progress ${url} ${files.convertToOSPath(appPath)}` + : `git clone --progress ${url} ${appPath}`; const [okClone, errClone] = await bash`${gitCommand}`; const errorMessage = errClone && typeof errClone === "string" ? errClone : errClone?.message; if (errorMessage && errorMessage.includes("Cloning into")) { From e866128231ecde23c52eb8aa77a1f0902e890e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 16:05:23 +0200 Subject: [PATCH 5/6] manage better env variables spread to git child processes --- tools/cli/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 12b82f99c0..ab2e89df55 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -35,7 +35,7 @@ const { exec } = require("child_process"); */ const runCommand = async (command) => { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { + exec(command, { env: process.env }, (error, stdout) => { if (error) { console.log(red`error: ${ error.message }`); reject(error); From 4cafa1863a0695c480cbbb8d767bbf68ac3f37c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 15 Jul 2024 16:07:58 +0200 Subject: [PATCH 6/6] manage better env variables spread to git child processes --- tools/cli/commands.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index ab2e89df55..95497cf1a5 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -1053,8 +1053,9 @@ main.registerCommand({ if (err) throw new Error("git is not installed"); const isWindows = process.platform === "win32"; - process.env.GIT_TERMINAL_PROMPT = 0; // Set GIT_TERMINAL_PROMPT=0 to disable prompting + process.env.GIT_TERMINAL_PROMPT = 0; + const gitCommand = isWindows ? `git clone --progress ${url} ${files.convertToOSPath(appPath)}` : `git clone --progress ${url} ${appPath}`;