An easy-to-use platform for EEG experimentation in the classroom
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

updates and rebase

+53 -39
+44 -37
internals/scripts/InstallPyodide.js
··· 1 - //mkdir app/utils/pyodide/src 1 + // mkdir app/utils/pyodide/src 2 2 // && cd app/utils/pyodide/src 3 3 // curl -LJO https://github.com/iodide-project/pyodide/releases/download/0.12.0/pyodide-build-0.12.0.tar.bz2 4 4 // tar xjf pyodide-build-0.12.0.tar.bz2 5 5 // rm pyodide-build-0.12.0.tar.bz2", 6 6 7 - import chalk from "chalk"; 8 - import os from "os"; 9 - import fs from "fs"; 10 - import https from "https"; 11 - import mkdirp from "mkdirp"; 12 - import tar from "tar-fs"; 13 - import url from "url"; 14 - import gunzip from "gunzip-maybe"; 7 + import chalk from 'chalk'; 8 + import fs from 'fs'; 9 + import https from 'https'; 10 + import mkdirp from 'mkdirp'; 11 + import tar from 'tar-fs'; 12 + import url from 'url'; 13 + import bz2 from 'unbzip2-stream'; 15 14 16 - const PYODIDE_VERSION = "0.12.0"; 15 + const PYODIDE_VERSION = '0.12.0'; 17 16 const TAR_NAME = `pyodide-build-${PYODIDE_VERSION}.tar.bz2`; 18 - const PYODIDE_DIR = "app/utils/pyodide/src/"; 17 + const TAR_URL = `https://github.com/iodide-project/pyodide/releases/download/${PYODIDE_VERSION}/pyodide-build-${PYODIDE_VERSION}.tar.bz2`; 18 + const PYODIDE_DIR = 'app/utils/pyodide/src/'; 19 19 20 20 const writeAndUnzipFile = response => { 21 21 const filePath = `${PYODIDE_DIR}${TAR_NAME}`; 22 22 const writeStream = fs.createWriteStream(filePath); 23 23 response.pipe(writeStream); 24 24 25 - writeStream.on("finish", () => { 25 + writeStream.on('finish', () => { 26 26 console.log(`${chalk.green.bold(`Unzipping pyodide`)}`); 27 27 28 28 const readStream = fs.createReadStream(filePath); 29 - readStream.pipe(gunzip()).pipe(tar.extract(PYODIDE_DIR)); 29 + try { 30 + readStream.pipe(bz2()).pipe(tar.extract(PYODIDE_DIR)); 31 + } catch (e) { 32 + throw new Error('Error in unzip:', e); 33 + } 30 34 31 - readStream.on("end", () => { 35 + readStream.on('end', () => { 32 36 console.log(`${chalk.green.bold(`Unzip successful`)}`); 33 37 }); 34 38 }); 35 39 }; 36 40 41 + const downloadFile = response => { 42 + if ( 43 + response.statusCode > 300 && 44 + response.statusCode < 400 && 45 + response.headers.location 46 + ) { 47 + if (url.parse(response.headers.location).hostname) { 48 + https.get(response.headers.location, writeAndUnzipFile); 49 + } else { 50 + https.get( 51 + url.resolve(url.parse(TAR_URL).hostname, response.headers.location), 52 + writeAndUnzipFile 53 + ); 54 + } 55 + } else { 56 + writeAndUnzipFile(response); 57 + } 58 + }; 59 + 37 60 (() => { 61 + if (fs.existsSync(`${PYODIDE_DIR}${TAR_NAME}`)) { 62 + console.log( 63 + `${chalk.green.bold(`Pyodide is already present: ${PYODIDE_VERSION}...`)}` 64 + ); 65 + return; 66 + } 38 67 console.log( 39 68 `${chalk.green.bold(`Downloading pyodide ${PYODIDE_VERSION}...`)}` 40 69 ); 41 - 42 70 mkdirp.sync(`app/utils/pyodide/src`); 43 - 44 - https.get( 45 - `https://github.com/iodide-project/pyodide/releases/download/${PYODIDE_VERSION}/pyodide-build-${PYODIDE_VERSION}.tar.bz2`, 46 - response => { 47 - if ( 48 - response.statusCode > 300 && 49 - response.statusCode < 400 && 50 - response.headers.location 51 - ) { 52 - if (url.parse(response.headers.location).hostname) { 53 - https.get(response.headers.location, writeAndUnzipFile); 54 - } else { 55 - https.get( 56 - url.resolve(url.parse(TAR_URL).hostname, response.headers.location), 57 - writeToFile 58 - ); 59 - } 60 - } else { 61 - writeAndUnzipFile(response); 62 - } 63 - } 64 - ); 71 + https.get(TAR_URL, downloadFile); 65 72 })();
+9 -2
package.json
··· 37 37 "test-watch": "yarn test --watch" 38 38 }, 39 39 "lint-staged": { 40 - "*.{js,jsx,ts,tsx}": ["cross-env NODE_ENV=development eslint --cache"], 40 + "*.{js,jsx,ts,tsx}": [ 41 + "cross-env NODE_ENV=development eslint --cache" 42 + ], 41 43 "{*.json,.{babelrc,eslintrc,prettierrc,stylelintrc}}": [ 42 44 "prettier --ignore-path .eslintignore --parser json --write" 43 45 ], ··· 45 47 "stylelint --ignore-path .eslintignore --syntax scss --fix", 46 48 "prettier --ignore-path .eslintignore --single-quote --write" 47 49 ], 48 - "*.{html,md,yml}": ["prettier --ignore-path .eslintignore --single-quote --write"] 50 + "*.{html,md,yml}": [ 51 + "prettier --ignore-path .eslintignore --single-quote --write" 52 + ] 49 53 }, 50 54 "build": { 51 55 "productName": "BrainWaves", ··· 53 57 "files": [ 54 58 "dist/", 55 59 "node_modules/", 60 + "assets/", 61 + "utils/pyodide/utils.py", 62 + "utils/pyodide/pyimport.py", 56 63 "app.html", 57 64 "main.prod.js", 58 65 "main.prod.js.map",