mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2025-12-09 14:30:42 -07:00
Update node_modules
This commit is contained in:
38
src/decompress-tarxz.d.ts
vendored
38
src/decompress-tarxz.d.ts
vendored
@@ -1,38 +0,0 @@
|
||||
export = decompresstarxz;
|
||||
|
||||
declare function decompresstarxz(
|
||||
input: string | Buffer,
|
||||
output?: string | decompresstarxz.DecompressOptions,
|
||||
opts?: decompresstarxz.DecompressOptions
|
||||
): Promise<decompresstarxz.File[]>;
|
||||
|
||||
declare namespace decompresstarxz {
|
||||
interface File {
|
||||
data: Buffer;
|
||||
mode: number;
|
||||
mtime: string;
|
||||
path: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface DecompressOptions {
|
||||
/**
|
||||
* Filter out files before extracting
|
||||
*/
|
||||
filter?(file: File): boolean;
|
||||
/**
|
||||
* Map files before extracting
|
||||
*/
|
||||
map?(file: File): File;
|
||||
/**
|
||||
* Array of plugins to use.
|
||||
* Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]
|
||||
*/
|
||||
plugins?: any[];
|
||||
/**
|
||||
* Remove leading directory components from extracted files.
|
||||
* Default: 0
|
||||
*/
|
||||
strip?: number;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import decompress = require('decompress');
|
||||
import decompresstarxz = require('decompress-tarxz');
|
||||
import * as download from 'download';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
import * as restm from 'typed-rest-client/RestClient';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
let osPlat: string = os.platform();
|
||||
let osArch: string = os.arch();
|
||||
@@ -16,33 +16,38 @@ export async function getUPX(version: string): Promise<string> {
|
||||
version = selected;
|
||||
}
|
||||
|
||||
console.log(`✅ UPX version found: ${version}`);
|
||||
core.info(`✅ UPX version found: ${version}`);
|
||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'upx-'));
|
||||
const fileName = getFileName(version);
|
||||
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', version, fileName);
|
||||
|
||||
console.log(`⬇️ Downloading ${downloadUrl}...`);
|
||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||
await download.default(downloadUrl, tmpdir, {filename: fileName});
|
||||
|
||||
console.log('📦 Extracting UPX...');
|
||||
core.info('📦 Extracting UPX...');
|
||||
let extPath: string = tmpdir;
|
||||
if (osPlat == 'win32') {
|
||||
await decompress(`${tmpdir}/${fileName}`, tmpdir, {strip: 1});
|
||||
extPath = await tc.extractZip(`${tmpdir}/${fileName}`);
|
||||
} else {
|
||||
await decompresstarxz(`${tmpdir}/${fileName}`, tmpdir, {strip: 1});
|
||||
extPath = await tc.extractTar(`${tmpdir}/${fileName}`, undefined, 'x');
|
||||
}
|
||||
|
||||
return path.join(tmpdir, osPlat == 'win32' ? 'upx.exe' : 'upx');
|
||||
return path.join(extPath, getFileNameWithoutExt(version), osPlat == 'win32' ? 'upx.exe' : 'upx');
|
||||
}
|
||||
|
||||
function getFileName(version: string): string {
|
||||
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.xz';
|
||||
return util.format('%s.%s', getFileNameWithoutExt(version), ext);
|
||||
}
|
||||
|
||||
function getFileNameWithoutExt(version: string): string {
|
||||
let platform: string = '';
|
||||
if (osPlat == 'win32') {
|
||||
platform = osArch == 'x64' ? 'win64' : 'win32';
|
||||
} else if (osPlat == 'linux') {
|
||||
platform = osArch == 'x64' ? 'amd64_linux' : 'i386_linux';
|
||||
}
|
||||
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.xz';
|
||||
return util.format('upx-%s-%s.%s', version, platform, ext);
|
||||
return util.format('upx-%s-%s', version, platform);
|
||||
}
|
||||
|
||||
interface GitHubRelease {
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import * as installer from './installer';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
export async function run(silent?: boolean) {
|
||||
try {
|
||||
if (os.platform() == 'darwin') {
|
||||
core.setFailed('Not supported on darwin platform');
|
||||
return;
|
||||
}
|
||||
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const file = core.getInput('file', {required: true});
|
||||
const args = core.getInput('args');
|
||||
|
||||
Reference in New Issue
Block a user