From 9cd4893e3ea23f0ee63af2c001303d39a2e1cf72 Mon Sep 17 00:00:00 2001 From: war-in Date: Wed, 17 Jan 2024 15:36:57 +0100 Subject: [PATCH 1/6] download USC --- dist/index.js | 10 ++++++++++ lib/download.js | 9 +++++++++ lib/main.js | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 25c0b1d..7d8ca17 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29963,6 +29963,15 @@ async function findStarknetFoundryDir(extractedPath) { ); } +async function downloadUniversalSierraCompiler() { + const { exec } = __nccwpck_require__(2081); + + const command = + "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; + + exec(command); +} + ;// CONCATENATED MODULE: ./lib/main.js @@ -29995,6 +30004,7 @@ async function main() { triplet, ); if (!StarknetFoundryPrefix) { + await downloadUniversalSierraCompiler(); const download = await downloadStarknetFoundry( StarknetFoundryRepo, StarknetFoundryVersion, diff --git a/lib/download.js b/lib/download.js index aefa596..00da288 100644 --- a/lib/download.js +++ b/lib/download.js @@ -37,3 +37,12 @@ async function findStarknetFoundryDir(extractedPath) { `could not find Starknet Foundry directory in ${extractedPath}`, ); } + +export async function downloadUniversalSierraCompiler() { + const { exec } = require("child_process"); + + const command = + "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; + + exec(command); +} diff --git a/lib/main.js b/lib/main.js index 118c155..bc027c5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -3,7 +3,10 @@ import { getFullVersionFromStarknetFoundry, versionWithPrefix, } from "./versions"; -import { downloadStarknetFoundry } from "./download"; +import { + downloadStarknetFoundry, + downloadUniversalSierraCompiler, +} from "./download"; import { getOsTriplet } from "./platform"; import path from "path"; import * as core from "@actions/core"; @@ -33,6 +36,7 @@ export default async function main() { triplet, ); if (!StarknetFoundryPrefix) { + await downloadUniversalSierraCompiler(); const download = await downloadStarknetFoundry( StarknetFoundryRepo, StarknetFoundryVersion, From 519d8ba918f9b329fbd3d21fab67f11752f4db3a Mon Sep 17 00:00:00 2001 From: war-in Date: Wed, 17 Jan 2024 15:46:24 +0100 Subject: [PATCH 2/6] add logs --- lib/download.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/download.js b/lib/download.js index 00da288..f97190f 100644 --- a/lib/download.js +++ b/lib/download.js @@ -44,5 +44,13 @@ export async function downloadUniversalSierraCompiler() { const command = "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; - exec(command); + exec(command, (error, stdout, stderr) => { + if (error) { + console.error(`Error while installing \`universal-sierra-compiler\`: ${error.message}`); + console.error(`Stderr: ${stderr}`) + return; + } + + console.log(`Successfully installed \`universal-sierra-compiler\``); + }); } From 3b298c29a2ec180ec95b95f5b244d146c46c52a5 Mon Sep 17 00:00:00 2001 From: war-in Date: Wed, 17 Jan 2024 15:47:12 +0100 Subject: [PATCH 3/6] fmt & build --- dist/index.js | 12 +++++++++++- lib/download.js | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7d8ca17..ce843d2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29969,7 +29969,17 @@ async function downloadUniversalSierraCompiler() { const command = "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; - exec(command); + exec(command, (error, stdout, stderr) => { + if (error) { + console.error( + `Error while installing \`universal-sierra-compiler\`: ${error.message}`, + ); + console.error(`Stderr: ${stderr}`); + return; + } + + console.log(`Successfully installed \`universal-sierra-compiler\``); + }); } ;// CONCATENATED MODULE: ./lib/main.js diff --git a/lib/download.js b/lib/download.js index f97190f..c0f1c38 100644 --- a/lib/download.js +++ b/lib/download.js @@ -46,8 +46,10 @@ export async function downloadUniversalSierraCompiler() { exec(command, (error, stdout, stderr) => { if (error) { - console.error(`Error while installing \`universal-sierra-compiler\`: ${error.message}`); - console.error(`Stderr: ${stderr}`) + console.error( + `Error while installing \`universal-sierra-compiler\`: ${error.message}`, + ); + console.error(`Stderr: ${stderr}`); return; } From 9e8e4d72e8a56443419b56b189cce3819fd30309 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Jan 2024 15:30:25 +0100 Subject: [PATCH 4/6] use appropriate modules --- dist/index.js | 24 +++++++++++------------- lib/download.js | 27 ++++++++++++--------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/dist/index.js b/dist/index.js index ce843d2..14e3857 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29964,22 +29964,20 @@ async function findStarknetFoundryDir(extractedPath) { } async function downloadUniversalSierraCompiler() { - const { exec } = __nccwpck_require__(2081); + const exec = __nccwpck_require__(1514); - const command = - "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; + const scriptUrl = + "https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh"; - exec(command, (error, stdout, stderr) => { - if (error) { - console.error( - `Error while installing \`universal-sierra-compiler\`: ${error.message}`, - ); - console.error(`Stderr: ${stderr}`); - return; - } + try { + const scriptPath = await tool_cache.downloadTool(scriptUrl); - console.log(`Successfully installed \`universal-sierra-compiler\``); - }); + await exec.exec(`chmod +x ${scriptPath}`); + + await exec.exec(scriptPath); + } catch (error) { + core.setFailed(error.message); + } } ;// CONCATENATED MODULE: ./lib/main.js diff --git a/lib/download.js b/lib/download.js index c0f1c38..1dc32d0 100644 --- a/lib/download.js +++ b/lib/download.js @@ -2,6 +2,7 @@ import path from "path"; import fs from "fs/promises"; import * as core from "@actions/core"; import * as tc from "@actions/tool-cache"; +import * as exec from "@actions/exec"; import { getOsTriplet } from "./platform"; import { versionWithPrefix } from "./versions"; @@ -39,20 +40,16 @@ async function findStarknetFoundryDir(extractedPath) { } export async function downloadUniversalSierraCompiler() { - const { exec } = require("child_process"); - - const command = - "curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh"; - - exec(command, (error, stdout, stderr) => { - if (error) { - console.error( - `Error while installing \`universal-sierra-compiler\`: ${error.message}`, - ); - console.error(`Stderr: ${stderr}`); - return; - } + const scriptUrl = + "https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh"; + + try { + const scriptPath = await tc.downloadTool(scriptUrl); - console.log(`Successfully installed \`universal-sierra-compiler\``); - }); + await exec.exec(`chmod +x ${scriptPath}`); + + await exec.exec(scriptPath); + } catch (error) { + core.setFailed(error.message); + } } From 797af081aee5d09c4c1fc098e2b414af7ab4eb04 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Jan 2024 15:30:43 +0100 Subject: [PATCH 5/6] build --- dist/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 14e3857..3b94530 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29930,6 +29930,7 @@ function getOsPlatform() { + async function downloadStarknetFoundry(repo, version) { const triplet = getOsTriplet(); const tag = versionWithPrefix(version); @@ -29964,8 +29965,6 @@ async function findStarknetFoundryDir(extractedPath) { } async function downloadUniversalSierraCompiler() { - const exec = __nccwpck_require__(1514); - const scriptUrl = "https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh"; From d5714413cd9d9f32b7589ab34abf56f625bd7f51 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Jan 2024 15:33:21 +0100 Subject: [PATCH 6/6] add `Verify universal-sierra-compiler installation` CI step --- .github/workflows/checks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 427b526..ea1fca6 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,6 +47,9 @@ jobs: with: starknet-foundry-version: latest + - name: Verify universal-sierra-compiler installation + run: universal-sierra-compiler --version + - name: Create new project run: snforge init myproject