@@ -35,27 +35,68 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3535 return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
3636} ;
3737Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
38- exports . installReviewDog = exports . installLint = void 0 ;
38+ exports . installReviewDog = exports . installLint = exports . getSupportedSystem = void 0 ;
3939const core = __importStar ( require ( "@actions/core" ) ) ;
4040const tc = __importStar ( require ( "@actions/tool-cache" ) ) ;
41- const node_fetch_1 = __importDefault ( require ( "node-fetch" ) ) ;
4241const path_1 = __importDefault ( require ( "path" ) ) ;
4342const releases = 'https://github.com/errata-ai/vale/releases/download' ;
4443const last = 'https://github.com/errata-ai/vale/releases/latest/' ;
44+ var RunnerOS ;
45+ ( function ( RunnerOS ) {
46+ RunnerOS [ "LINUX" ] = "Linux" ;
47+ RunnerOS [ "MAC" ] = "macOS" ;
48+ RunnerOS [ "WINDOWS" ] = "Windows" ;
49+ } ) ( RunnerOS || ( RunnerOS = { } ) ) ;
50+ var RunnerArch ;
51+ ( function ( RunnerArch ) {
52+ RunnerArch [ "X86" ] = "X86" ;
53+ RunnerArch [ "X64" ] = "X64" ;
54+ RunnerArch [ "ARM" ] = "ARM" ;
55+ RunnerArch [ "ARM64" ] = "ARM64" ;
56+ } ) ( RunnerArch || ( RunnerArch = { } ) ) ;
57+ const os = process . env . RUNNER_OS ;
58+ const arch = process . env . RUNNER_ARCH ;
59+ const system = { os, arch } ;
60+ const supportedSystems = [
61+ {
62+ system : { os : RunnerOS . LINUX , arch : RunnerArch . X64 } ,
63+ tools : {
64+ vale : 'Linux_64-bit.tar.gz' ,
65+ reviewdog : 'Linux_x86_64.tar.gz'
66+ }
67+ } ,
68+ {
69+ system : { os : RunnerOS . LINUX , arch : RunnerArch . ARM64 } ,
70+ tools : {
71+ vale : 'Linux_arm64.tar.gz' ,
72+ reviewdog : 'Linux_arm64.tar.gz'
73+ }
74+ }
75+ ] ;
76+ function getSupportedSystem ( ) {
77+ for ( const supportedSystem of supportedSystems ) {
78+ if ( supportedSystem . system . os === system . os && supportedSystem . system . arch === system . arch ) {
79+ return supportedSystem ;
80+ }
81+ }
82+ throw new Error ( `Unsupported system: ${ JSON . stringify ( system ) } ` ) ;
83+ }
84+ exports . getSupportedSystem = getSupportedSystem ;
4585function installLint ( version ) {
4686 return __awaiter ( this , void 0 , void 0 , function * ( ) {
87+ const supportedSystem = getSupportedSystem ( ) ;
4788 core . info ( `Installing Vale version '${ version } ' ...` ) ;
4889 if ( version === 'latest' ) {
49- const response = yield ( 0 , node_fetch_1 . default ) ( last ) ;
90+ const response = yield fetch ( last ) ;
5091 const vs = response . url ;
5192 const parts = vs . split ( `/` ) ;
5293 version = parts [ parts . length - 1 ] . substring ( 1 ) ;
5394 }
54- const url = releases + `/v${ version } /vale_${ version } _Linux_64-bit.tar.gz ` ;
95+ const url = releases + `/v${ version } /vale_${ version } _ ${ supportedSystem . tools . vale } ` ;
5596 const archivePath = yield tc . downloadTool ( url ) ;
5697 let extractedDir = '' ;
5798 const args = [ 'xz' ] ;
58- if ( process . platform . toString ( ) != 'darwin' ) {
99+ if ( os != RunnerOS . MAC ) {
59100 args . push ( '--overwrite' ) ;
60101 }
61102 extractedDir = yield tc . extractTar ( archivePath , process . env . HOME , args ) ;
@@ -67,14 +108,15 @@ function installLint(version) {
67108exports . installLint = installLint ;
68109function installReviewDog ( version , url ) {
69110 return __awaiter ( this , void 0 , void 0 , function * ( ) {
111+ const supportedSystem = getSupportedSystem ( ) ;
70112 core . info ( `Installing ReviewDog version '${ version } ' ...` ) ;
71113 if ( ! url ) {
72- url = `https://github.com/reviewdog/reviewdog/releases/download/v${ version } /reviewdog_${ version } _Linux_x86_64.tar.gz ` ;
114+ url = `https://github.com/reviewdog/reviewdog/releases/download/v${ version } /reviewdog_${ version } _ ${ supportedSystem . tools . reviewdog } ` ;
73115 }
74116 const archivePath = yield tc . downloadTool ( url ) ;
75117 let extractedDir = '' ;
76118 const args = [ 'xz' ] ;
77- if ( process . platform . toString ( ) != 'darwin' ) {
119+ if ( os != RunnerOS . MAC ) {
78120 args . push ( '--overwrite' ) ;
79121 }
80122 extractedDir = yield tc . extractTar ( archivePath , process . env . HOME , args ) ;
0 commit comments