@@ -33948,113 +33948,100 @@ module.exports = parseParams
33948
33948
var __webpack_exports__ = {};
33949
33949
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
33950
33950
(() => {
33951
- const os = __nccwpck_require__(2037);
33952
33951
const semver = __nccwpck_require__(1383);
33953
33952
const path = __nccwpck_require__(1017);
33954
33953
const core = __nccwpck_require__(2186);
33955
33954
const tc = __nccwpck_require__(7784);
33956
33955
const exec = __nccwpck_require__(1514);
33956
+ const fs = (__nccwpck_require__(7147).promises);
33957
33957
33958
33958
const ovrPlatformUtil = 'ovr-platform-util';
33959
33959
const IS_WINDOWS = process.platform === 'win32'
33960
33960
const IS_MAC = process.platform === 'darwin'
33961
+ const toolExtension = IS_WINDOWS ? '.exe' : '';
33962
+ const toolPath = `${ovrPlatformUtil}${toolExtension}`;
33961
33963
33962
33964
const main = async () => {
33963
33965
try {
33964
- const fileEx = IS_WINDOWS ? '.exe' : '';
33965
- let osPlatform = os.platform();
33966
- let pathToModule = undefined;
33967
- let pathToToolDir = tc.find(ovrPlatformUtil, '1.98.0');
33968
-
33969
- if (!pathToToolDir) {
33970
- let url = undefined;
33971
- let downloadPath = undefined;
33972
-
33973
- if (IS_MAC) {
33974
- url = 'https://www.oculus.com/download_app/?id=1462426033810370';
33975
- } else if (IS_WINDOWS) {
33976
- url = 'https://www.oculus.com/download_app/?id=1076686279105243';
33977
- } else {
33978
- throw Error(`${ovrPlatformUtil} not available for ${osPlatform}`);
33979
- }
33980
-
33981
- let fileName = `${ovrPlatformUtil}${fileEx}`;
33982
- downloadPath = path.resolve(getTempDirectory(), fileName);
33983
-
33984
- core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${downloadPath}`);
33985
-
33986
- try {
33987
- downloadPath = await tc.downloadTool(url, downloadPath);
33988
- } catch (error) {
33989
- throw error;
33990
- }
33991
-
33992
- core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${downloadPath}`);
33993
-
33994
- if (IS_MAC) {
33995
- await exec.exec(`chmod +x ${downloadPath}`);
33996
- }
33997
-
33998
- const downloadVersion = await getVersion(downloadPath);
33999
- core.debug(`Setting tool cache: ${downloadPath} | ${fileName} | ${ovrPlatformUtil} | ${downloadVersion}`);
34000
- pathToToolDir = await tc.cacheFile(downloadPath, fileName, ovrPlatformUtil, downloadVersion);
34001
- pathToModule = getExecutable(pathToToolDir);
34002
- } else {
34003
- pathToModule = getExecutable(pathToToolDir);
34004
- await exec.exec(pathToModule, 'self-update');
34005
- }
34006
-
34007
- core.debug(`${ovrPlatformUtil} -> ${pathToModule}`);
34008
- core.addPath(pathToToolDir);
34009
- core.exportVariable(ovrPlatformUtil, pathToModule);
34010
-
34011
- await exec.exec(pathToModule, 'help');
33966
+ core.info(`Setting up ${ovrPlatformUtil}...`);
33967
+ await setup_ovrPlatformUtil();
34012
33968
} catch (error) {
34013
33969
core.setFailed(error);
34014
33970
}
34015
33971
}
34016
33972
34017
33973
main();
34018
33974
33975
+ async function setup_ovrPlatformUtil() {
33976
+ let toolDirectory = tc.find(ovrPlatformUtil, '*');
33977
+ let tool = undefined;
33978
+ if (!toolDirectory) {
33979
+ const url = getDownloadUrl();
33980
+ const archiveDownloadPath = path.resolve(getTempDirectory(), toolPath);
33981
+ core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${archiveDownloadPath}`);
33982
+ const archivePath = await tc.downloadTool(url, archiveDownloadPath);
33983
+ core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${archivePath}`);
33984
+ if (IS_MAC) {
33985
+ await exec.exec(`chmod +x ${archivePath}`);
33986
+ }
33987
+ const downloadVersion = await getVersion(archivePath);
33988
+ core.debug(`Setting tool cache: ${archivePath} | ${toolPath} | ${ovrPlatformUtil} | ${downloadVersion}`);
33989
+ toolDirectory = await tc.cacheFile(archivePath, toolPath, ovrPlatformUtil, downloadVersion);
33990
+ tool = getExecutable(toolDirectory);
33991
+ } else {
33992
+ tool = getExecutable(toolDirectory);
33993
+ fs.access(tool);
33994
+ core.debug(`Found ${tool} in ${toolDirectory}`);
33995
+ await exec.exec(tool, 'self-update');
33996
+ }
33997
+ core.debug(`${ovrPlatformUtil} -> ${toolDirectory}`)
33998
+ core.addPath(toolDirectory);
33999
+ await exec.exec(ovrPlatformUtil, 'help');
34000
+ }
34001
+
34002
+ function getDownloadUrl() {
34003
+ if (IS_MAC) {
34004
+ return 'https://www.oculus.com/download_app/?id=1462426033810370';
34005
+ } else if (IS_WINDOWS) {
34006
+ return 'https://www.oculus.com/download_app/?id=1076686279105243';
34007
+ } else {
34008
+ throw Error(`${ovrPlatformUtil} not available for ${process.platform}`);
34009
+ }
34010
+ }
34011
+
34019
34012
function getTempDirectory() {
34020
34013
const tempDirectory = process.env['RUNNER_TEMP'] || ''
34021
34014
return tempDirectory
34022
34015
}
34023
34016
34024
- function getExecutable(dir) {
34025
- const fileEx = IS_WINDOWS ? '.exe' : '';
34026
- const moduleName = `${ovrPlatformUtil}${fileEx}`;
34027
- return path.resolve(dir, moduleName);
34017
+ function getExecutable(directory) {
34018
+ return path.resolve(directory, toolPath);
34028
34019
}
34029
34020
34030
- async function getVersion(module ) {
34021
+ async function getVersion(tool ) {
34031
34022
const semVerRegEx = new RegExp(/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)?/);
34032
34023
let output = '';
34033
34024
34034
- await exec.exec(module , 'version', {
34025
+ await exec.exec(tool , 'version', {
34035
34026
listeners: {
34036
34027
stdout: (data) => {
34037
34028
output += data.toString();
34038
34029
}
34039
34030
}
34040
34031
});
34041
-
34042
34032
const match = output.match(semVerRegEx)[0];
34043
-
34044
34033
if (!match) {
34045
34034
throw Error("Failed to find a valid version match");
34046
34035
}
34047
-
34048
34036
const lastPeriodIndex = match.lastIndexOf('.');
34049
34037
const semVerStr = match.substring(0, lastPeriodIndex) + '+' + match.substring(lastPeriodIndex + 1);
34050
34038
const version = semver.clean(semVerStr);
34051
-
34052
34039
if (!version) {
34053
34040
throw Error("Failed to find a valid version");
34054
34041
}
34055
-
34056
34042
return version
34057
34043
}
34044
+
34058
34045
})();
34059
34046
34060
34047
module.exports = __webpack_exports__;
0 commit comments