diff --git a/.circleci/config.yml b/.circleci/config.yml index 654fa0658b..2821756cb9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,16 +24,26 @@ jobs: key: v1-deps-{{ checksum "yarn.lock" }} paths: - node_modules - - run: name: Build command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then - NX_BIN_URL=http://127.0.0.1:8080/assets/js NX_WASM_URL=http://127.0.0.1:8080/assets/js NPM_URL=http://localhost:9090/ yarn build:production + NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NPM_URL=http://localhost:9090/ yarn build:production else - NX_BIN_URL=http://127.0.0.1:8080/assets/js NX_WASM_URL=http://127.0.0.1:8080/assets/js NPM_URL=http://localhost:9090/ yarn build + NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NPM_URL=http://localhost:9090/ yarn build fi - run: yarn run build:e2e + + - run: grep -ir "[0-9]+commit" apps/* libs/* --include \*.ts --include \*.tsx --include \*.json > soljson-versions.txt + - restore_cache: + keys: + - soljson-v7-{{ checksum "soljson-versions.txt" }} + - run: yarn run downloadsolc_assets_e2e + - save_cache: + key: soljson-v7-{{ checksum "soljson-versions.txt" }} + paths: + - dist/apps/remix-ide/assets/js/soljson + - run: mkdir persist && zip -0 -r persist/dist.zip dist - persist_to_workspace: root: . @@ -155,7 +165,7 @@ jobs: at: . - run: unzip ./persist/dist.zip - run: yarn install --cwd ./apps/remix-ide-e2e --modules-folder ../../node_modules - - run: yarn run downloadsolc_assets_e2e + - run: ls -la ./dist/apps/remix-ide/assets/js - run: yarn run selenium-install || yarn run selenium-install - run: @@ -202,7 +212,6 @@ jobs: - run: unzip ./persist/dist.zip - run: unzip ./persist/plugin-<< parameters.plugin >>.zip - run: yarn install --cwd ./apps/remix-ide-e2e --modules-folder ../../node_modules - - run: yarn run downloadsolc_assets_e2e - run: yarn run selenium-install || yarn run selenium-install - run: name: Start Selenium diff --git a/apps/remix-ide/.gitignore b/apps/remix-ide/.gitignore index cf8c2c0ad3..3e0c4b3136 100644 --- a/apps/remix-ide/.gitignore +++ b/apps/remix-ide/.gitignore @@ -13,4 +13,4 @@ TODO .tern-port temp_publish_docker src/assets/version.json -src/assets/js/soljson-v* \ No newline at end of file +src/assets/js/soljson/soljson-v* \ No newline at end of file diff --git a/apps/remix-ide/ci/download_e2e_assets.js b/apps/remix-ide/ci/download_e2e_assets.js index 11ff135020..51c161b895 100644 --- a/apps/remix-ide/ci/download_e2e_assets.js +++ b/apps/remix-ide/ci/download_e2e_assets.js @@ -1,77 +1,77 @@ -const testFolder = './apps/remix-ide-e2e/src/tests/'; const fs = require('fs'); +var child_process = require('child_process'); +const { exit } = require('process'); -let url = 'https://binaries.soliditylang.org/wasm/list.json' - -const axios = require('axios') - -// use axios to download the file -axios({ - url: url, - method: 'GET', -}).then((response) => { - - let info = response.data; - info.builds = info.builds.filter(build => build.path.indexOf('nightly') === -1) - for (let build of info.builds) { - - const buildurl = `https://solc-bin.ethereum.org/wasm/${build.path}`; - console.log(buildurl) - - const path = `./dist/apps/remix-ide/assets/js/${build.path}`; - // use axios to get the file - try { - axios({ - method: 'get', - url: buildurl, - }).then(function (response) { - fs.writeFile(path, response.data, function (err) { - if (err) { - console.log(err); - } - }) - }) - } catch (e) { - console.log('Failed to download ' + build.path + ' from ' + buildurl) - } +const child = child_process.spawnSync('grep -r --include="*.json" --include="*.ts" --include="*.tsx" "+commit" apps/**/* libs/**/*', [], { encoding: 'utf8', cwd: process.cwd(), shell: true }); + +if (child.error) { + console.log("ERROR: ", child); + exit(1); +} + + +let soljson =[]; - } +const quotedVersionsRegex = /['"v]\d*\.\d*\.\d*\+commit\.[\d\w]*/g; +let quotedVersionsRegexMatch = child.stdout.match(quotedVersionsRegex) +if(quotedVersionsRegexMatch){ + let soljson2 = quotedVersionsRegexMatch.map((item) => item.replace('\'', 'v').replace('"', 'v')) + console.log('non nightly soljson versions found: ', soljson2); + if(soljson2) soljson = soljson.concat(soljson2); } -) - -fs.readdirSync(testFolder).forEach(file => { - let c = fs.readFileSync(testFolder + file, 'utf8'); - const re = /(?<=soljson).*(?=(.js))/g; - const soljson = c.match(re); - if (soljson) { - for (let i = 0; i < soljson.length; i++) { - - const version = soljson[i]; - if (version && version.indexOf('nightly') > -1) { - const url = `https://solc-bin.ethereum.org/bin/soljson${version}.js`; - console.log(url) - - const path = `./dist/apps/remix-ide/assets/js/soljson${version}.js`; - // use axios to get the file + + +const nightlyVersionsRegex = /\d*\.\d*\.\d-nightly.*\+commit\.[\d\w]*/g +const nightlyVersionsRegexMatch = child.stdout.match(nightlyVersionsRegex) +if(nightlyVersionsRegexMatch){ + let soljson3 = nightlyVersionsRegexMatch.map((item) => 'v' + item); + console.log('nightly soljson versions found: ', soljson3); + if(soljson3) soljson = soljson.concat(soljson3); +} + +if (soljson) { + // filter out duplicates + soljson = soljson.filter((item, index) => soljson.indexOf(item) === index); + + // manually add some versions + soljson.push('v0.7.6+commit.7338295f'); + + console.log('soljson versions found: ', soljson, soljson.length); + + for (let i = 0; i < soljson.length; i++) { + const version = soljson[i]; + if (version) { + let url = '' + + // if nightly + if (version.includes('nightly')) { + url = `https://binaries.soliditylang.org/bin/soljson-${version}.js`; + }else{ + url = `https://binaries.soliditylang.org/wasm/soljson-${version}.js`; + } + + const dir = './dist/apps/remix-ide/assets/js/soljson'; + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + + const path = `./dist/apps/remix-ide/assets/js/soljson/soljson-${version}.js`; + // check if the file exists + const exists = fs.existsSync(path); + if (!exists) { + console.log('URL:', url) try { - axios({ - method: 'get', - url: url, - }).then(function (response) { - fs.writeFile(path, response.data, function (err) { - if (err) { - console.log(err); - } - }) - }) + // use curl to download the file + child_process.exec(`curl -o ${path} ${url}`, { encoding: 'utf8', cwd: process.cwd(), shell: true }) } catch (e) { console.log('Failed to download soljson' + version + ' from ' + url) } - - } + } - } + + } + +} -}); diff --git a/apps/remix-ide/ci/downloadsoljson.sh b/apps/remix-ide/ci/downloadsoljson.sh new file mode 100644 index 0000000000..b99ed2d6b0 --- /dev/null +++ b/apps/remix-ide/ci/downloadsoljson.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +echo "Downloading latest soljson.js from https://binaries.soliditylang.org/wasm/list.json" +set -e +# check if curl is installed +if ! command -v curl &> /dev/null +then + echo "curl could not be found" + exit +fi + + +# download https://binaries.soliditylang.org/wasm/list.json as json +curl -s https://binaries.soliditylang.org/wasm/list.json > list.json +# get the latest version without jq +latest=$(grep 'latestRelease' list.json | cut -d '"' -f 4) +echo "latest version: $latest" +# get url +url=$(grep "\"$latest\":" list.json | cut -d '"' -f 4) +echo "url: $url" +path="https://binaries.soliditylang.org/bin/$url" +echo "path: $path" +# download the file to ./apps/remix-ide/src/assets/js/soljson.js +curl -s $path > ./apps/remix-ide/src/assets/js/soljson.js +# if directory ./apps/remix-ide/src/assets/js/soljson does not exist, create it +if [ ! -d "./apps/remix-ide/src/assets/js/soljson" ]; then + mkdir ./apps/remix-ide/src/assets/js/soljson +fi +cp ./apps/remix-ide/src/assets/js/soljson.js ./apps/remix-ide/src/assets/js/soljson/$url + +# remove list.json +rm list.json + diff --git a/apps/remix-ide/project.json b/apps/remix-ide/project.json index 4e413240ee..15636c7961 100644 --- a/apps/remix-ide/project.json +++ b/apps/remix-ide/project.json @@ -52,6 +52,7 @@ "configurations": { "development": { "buildTarget": "remix-ide:build:development", + "host": "0.0.0.0", "port": 8080 }, "hot":{ diff --git a/apps/remix-ide/webpack.config.js b/apps/remix-ide/webpack.config.js index a10a6a3e47..a6aa923939 100644 --- a/apps/remix-ide/webpack.config.js +++ b/apps/remix-ide/webpack.config.js @@ -15,26 +15,10 @@ const versionData = { } const loadLocalSolJson = async () => { - let url = 'https://binaries.soliditylang.org/wasm/list.json' - axios({ - url: url, - method: 'GET', - }).then((response) => { - let info = response.data; - info.builds = info.builds.filter(build => build.path.indexOf('nightly') === -1) - info.builds = info.builds.slice(-1) - const buildurl = `https://solc-bin.ethereum.org/wasm/${info.builds[0].path}`; - console.log(`Copying... ${buildurl} to assets`) - const path = `./apps/remix-ide/src/assets/js/soljson.js`; - axios({ - method: 'get', - url: buildurl, - responseType: 'stream' - }).then(function (response) { - response.data.pipe(fs.createWriteStream(path)); - }) - } - ) + // execute apps/remix-ide/ci/downloadsoljson.sh + const child = require('child_process').execSync('bash ./apps/remix-ide/ci/downloadsoljson.sh', { encoding: 'utf8', cwd: process.cwd(), shell: true }) + // show output + console.log(child) } fs.writeFileSync('./apps/remix-ide/src/assets/version.json', JSON.stringify(versionData))