@@ -1967,72 +1967,113 @@ const core = __webpack_require__(470);
19671967const exec = __webpack_require__ ( 986 ) ;
19681968const fs = __webpack_require__ ( 747 ) ;
19691969const tmp = __webpack_require__ ( 150 ) ;
1970+ const path = __webpack_require__ ( 622 ) ;
1971+ const io = __webpack_require__ ( 1 ) ;
19701972
1971- const patform = process . platform ;
1973+ const platform = process . platform ;
19721974
19731975async function run ( ) {
19741976 try {
1977+
19751978 const osVersion = core . getInput ( 'version' ) ;
1976- var osVersionStr = getVersionString ( osVersion ) ;
1977- console . log ( 'Версия: ' + osVersionStr ) ;
1978- console . log ( 'Платформа: ' + patform )
1979- if ( patform == 'win32' ) {
1980- console . log ( 'Загрузка' ) ;
1981- await exec . exec ( 'curl -v https://oscript.io/downloads/' + osVersionStr + '/exe?bitness=x64 --output oscript.exe' ) ;
1982- console . log ( 'Установка' ) ;
1983- await exec . exec ( './oscript.exe /verysilent /norestart /log=oscript.log' ) ;
1984-
1985- console . log ( 'Лог установки' ) ;
1986- await exec . exec ( 'powershell Get-Content -Path oscript.log' ) ;
1987- console . log ( 'Обновление Path' ) ;
1988- updatePath ( ) ;
1989-
1990- console . log ( 'Удаление временного файла' ) ;
1991- fs . unlinkSync ( './oscript.exe' ) ;
1992-
1993- } else if ( patform == 'linux' ) {
1979+
1980+ console . log ( 'OS: ' + platform ) ;
1981+
1982+ if ( ! ( platform == 'win32' || platform == 'linux' || platform == 'darwin' ) ) {
1983+ throw new Error ( 'OS not support' ) ;
1984+ }
1985+
1986+ if ( core . isDebug ( ) ) {
1987+ core . exportVariable ( 'LOGOS_CONFIG' , "logger.rootLogger=DEBUG" ) ;
1988+ }
1989+
1990+ let pathToOVM = 'ovm.exe' ;
1991+ if ( platform == 'win32' ) {
1992+ pathToOVM = path . dirname ( __dirname ) + '/' + 'ovm.exe' ;
1993+ }
1994+ await exec . exec ( 'curl -L https://github.com/oscript-library/ovm/releases/download/v1.0.0-RC15/ovm.exe --output ' + pathToOVM ) ;
1995+
1996+ if ( platform == 'win32' ) {
1997+ let pathToOVM = path . dirname ( __dirname ) ;
1998+ console . log ( "dir: " + pathToOVM ) ;
1999+ core . addPath ( pathToOVM ) ;
2000+ }
2001+
2002+ if ( platform == 'linux' ) {
2003+
19942004 var tmpFile = tmp . fileSync ( ) ;
1995- fs . writeFileSync ( tmpFile . name , installLinux ( osVersionStr , 'x64' ) ) ;
2005+ fs . writeFileSync ( tmpFile . name , installLinux ( ) ) ;
2006+ await exec . exec ( 'bash ' + tmpFile . name ) ;
2007+ fs . unlinkSync ( tmpFile . name ) ;
2008+
2009+ }
19962010
2011+ if ( platform == 'darwin' ) {
2012+ var tmpFile = tmp . fileSync ( ) ;
2013+ fs . writeFileSync ( tmpFile . name , installMacOs ( ) ) ;
19972014 await exec . exec ( 'bash ' + tmpFile . name ) ;
19982015 fs . unlinkSync ( tmpFile . name ) ;
1999- await exec . exec ( 'curl -v https://hub.oscript.io/download/opm/opm.ospx --output opm.ospx' ) ;
2000- await exec . exec ( 'sudo opm install -f opm.ospx' ) ;
2001- fs . unlinkSync ( 'opm.ospx' ) ;
2002-
2003- await exec . exec ( 'oscript --version' ) ;
2016+ }
2017+
2018+ await exec . exec ( 'ovm install ' + osVersion ) ;
2019+ await exec . exec ( 'ovm use ' + osVersion ) ;
2020+
2021+ let output = '' ;
2022+ const options = { } ;
2023+ options . listeners = {
2024+ stdout : ( data ) => {
2025+ output += data . toString ( ) ;
2026+ }
2027+ } ;
2028+ await exec . exec ( 'ovm' , [ 'which' , 'current' ] , options ) ;
2029+ let pathOscript = path . dirname ( output ) ;
2030+
2031+ core . addPath ( pathOscript ) ;
2032+
2033+ if ( platform != 'win32' ) {
2034+ core . exportVariable ( 'OSCRIPTBIN' , pathOscript ) ;
2035+ core . exportVariable ( 'PATH' , '$OSCRIPTBIN:' + process . env . PATH ) ;
2036+ }
20042037
2005- } else {
2006- throw new Error ( 'OS not support' ) ;
2038+ if ( platform == 'linux' ) {
2039+ await exec . exec ( 'curl -L https://github.com/oscript-library/opm/releases/download/v0.16.2/opm-0.16.2.ospx --output opm.ospx' ) ;
2040+ if ( osVersion == '1.2.0' ) {
2041+ await exec . exec ( 'mkdir tmp' ) ;
2042+ await exec . exec ( 'unzip opm.ospx -d tmp' ) ;
2043+ await exec . exec ( 'unzip -o ./tmp/content.zip -d /home/runner/.local/share/ovm/current/lib/opm' ) ;
2044+ }
2045+ await exec . exec ( 'opm install -f opm.ospx' ) ;
20072046 }
20082047 }
20092048 catch ( error ) {
20102049 core . setFailed ( error . message ) ;
20112050 }
20122051}
20132052
2014- function getVersionString ( value ) {
2015- var version = value . split ( '.' ) . join ( '_' ) ;
2016- return version ;
2017- }
2053+ function installLinux ( ) {
2054+ var value = [ ] ;
2055+ value . push ( '#!/bin/bash' ) ;
2056+ value . push ( 'sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF' ) ;
2057+ value . push ( 'echo "deb http://download.mono-project.com/repo/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/mono-official.list' ) ;
2058+ value . push ( 'sudo apt-get update' ) ;
2059+ value . push ( 'sudo apt-get install mono-complete mono-devel' ) ;
2060+ value . push ( 'sudo mv ovm.exe /usr/local/bin/' ) ;
2061+
2062+ let cmd = 'mono /usr/local/bin/ovm.exe "$@"' ;
2063+ value . push ( "echo '" + cmd + "' | sudo tee /usr/local/bin/ovm" ) ;
20182064
2019- function updatePath ( ) {
2020- const OLD_PATH = process . env . PATH ;
2021- PATH = OLD_PATH + ";C:\/Program Files\/OneScript\/bin;" ;
2022- core . exportVariable ( 'Path' , PATH ) ;
2065+ value . push ( 'sudo chmod +x /usr/local/bin/ovm' ) ;
2066+ return value . join ( '\n' ) ;
20232067}
20242068
2025- function installLinux ( version , bitness ) {
2026- var value = [ ] ;
2027- value . push ( '#!/bin/bash' ) ;
2028- value . push ( 'sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF' ) ;
2029- value . push ( 'echo "deb http://download.mono-project.com/repo/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/mono-official.list' ) ;
2030- value . push ( 'sudo apt-get update' ) ;
2031- value . push ( 'sudo apt-get install mono-complete mono-devel' ) ;
2032- value . push ( 'curl -v https://oscript.io/downloads/' + version + '/deb?bitness=' + bitness + ' --output os.deb' ) ;
2033- value . push ( 'sudo dpkg -i os.deb' ) ;
2034- value . push ( 'sudo apt install -f' ) ;
2035- return value . join ( '\n' ) ;
2069+ function installMacOs ( ) {
2070+ var value = [ ] ;
2071+ value . push ( '#!/bin/bash' ) ;
2072+ value . push ( 'mv ovm.exe /usr/local/bin/' ) ;
2073+ let cmd = 'mono /usr/local/bin/ovm.exe "$@"' ;
2074+ value . push ( "echo '" + cmd + "' | tee /usr/local/bin/ovm" ) ;
2075+ value . push ( 'sudo chmod +x /usr/local/bin/ovm' ) ;
2076+ return value . join ( '\n' ) ;
20362077}
20372078
20382079run ( )
0 commit comments