From a40afdb08e9df36540fe028895ed89d35659b092 Mon Sep 17 00:00:00 2001 From: Matt Alioto Date: Fri, 29 May 2020 20:59:45 -0400 Subject: [PATCH] Try resetting line endings to fix the Mac side of the build --- dist/index.js | 1296 ++++++++++++++++++++++++------------------------- 1 file changed, 648 insertions(+), 648 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4e27086..390b972 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4936,127 +4936,127 @@ module.exports = Parser; /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.configAuthentication = void 0; -const fs = __importStar(__webpack_require__(747)); -const path = __importStar(__webpack_require__(622)); -const core = __importStar(__webpack_require__(470)); -const github = __importStar(__webpack_require__(469)); -const xmlbuilder = __importStar(__webpack_require__(312)); -const xmlParser = __importStar(__webpack_require__(989)); -function configAuthentication(feedUrl, existingFileLocation = '') { - const existingNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), existingFileLocation == '' ? 'nuget.config' : existingFileLocation); - const tempNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '../', 'nuget.config'); - writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); -} -exports.configAuthentication = configAuthentication; -function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { - console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); - let xml; - let sourceKeys = []; - let owner = core.getInput('owner'); - let sourceUrl = feedUrl; - if (!owner) { - owner = github.context.repo.owner; - } - if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') { - throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); - } - if (fs.existsSync(existingFileLocation)) { - // get key from existing NuGet.config so NuGet/dotnet can match credentials - const curContents = fs.readFileSync(existingFileLocation, 'utf8'); - var json = xmlParser.parse(curContents, { ignoreAttributes: false }); - if (typeof json.configuration == 'undefined') { - throw new Error(`The provided NuGet.config seems invalid.`); - } - if (typeof json.configuration.packageSources != 'undefined') { - if (typeof json.configuration.packageSources.add != 'undefined') { - // file has at least one - if (typeof json.configuration.packageSources.add[0] == 'undefined') { - // file has only one - if (json.configuration.packageSources.add['@_value'] - .toLowerCase() - .includes(feedUrl.toLowerCase())) { - let key = json.configuration.packageSources.add['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - else { - // file has 2+ - for (let i = 0; i < json.configuration.packageSources.add.length; i++) { - const source = json.configuration.packageSources.add[i]; - const value = source['@_value']; - core.debug(`source '${value}'`); - if (value.toLowerCase().includes(feedUrl.toLowerCase())) { - let key = source['@_key']; - sourceKeys.push(key); - core.debug(`Found a URL with key ${key}`); - } - } - } - } - } - } - xml = xmlbuilder - .create('configuration') - .ele('config') - .ele('add', { key: 'defaultPushSource', value: sourceUrl }) - .up() - .up(); - if (sourceKeys.length == 0) { - let keystring = 'Source'; - xml = xml - .ele('packageSources') - .ele('add', { key: keystring, value: sourceUrl }) - .up() - .up(); - sourceKeys.push(keystring); - } - xml = xml.ele('packageSourceCredentials'); - sourceKeys.forEach(key => { - if (key.indexOf(' ') > -1) { - throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."); - } - xml = xml - .ele(key) - .ele('add', { key: 'Username', value: owner }) - .up() - .ele('add', { - key: 'ClearTextPassword', - value: process.env.NUGET_AUTH_TOKEN - }) - .up() - .up(); - }); - // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), - // use this for the value above - // process.platform == 'win32' - // ? '%NUGET_AUTH_TOKEN%' - // : '$NUGET_AUTH_TOKEN' - var output = xml.end({ pretty: true }); - fs.writeFileSync(tempFileLocation, output); -} + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.configAuthentication = void 0; +const fs = __importStar(__webpack_require__(747)); +const path = __importStar(__webpack_require__(622)); +const core = __importStar(__webpack_require__(470)); +const github = __importStar(__webpack_require__(469)); +const xmlbuilder = __importStar(__webpack_require__(312)); +const xmlParser = __importStar(__webpack_require__(989)); +function configAuthentication(feedUrl, existingFileLocation = '') { + const existingNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), existingFileLocation == '' ? 'nuget.config' : existingFileLocation); + const tempNuGetConfig = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '../', 'nuget.config'); + writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); +} +exports.configAuthentication = configAuthentication; +function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { + console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); + let xml; + let sourceKeys = []; + let owner = core.getInput('owner'); + let sourceUrl = feedUrl; + if (!owner) { + owner = github.context.repo.owner; + } + if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') { + throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); + } + if (fs.existsSync(existingFileLocation)) { + // get key from existing NuGet.config so NuGet/dotnet can match credentials + const curContents = fs.readFileSync(existingFileLocation, 'utf8'); + var json = xmlParser.parse(curContents, { ignoreAttributes: false }); + if (typeof json.configuration == 'undefined') { + throw new Error(`The provided NuGet.config seems invalid.`); + } + if (typeof json.configuration.packageSources != 'undefined') { + if (typeof json.configuration.packageSources.add != 'undefined') { + // file has at least one + if (typeof json.configuration.packageSources.add[0] == 'undefined') { + // file has only one + if (json.configuration.packageSources.add['@_value'] + .toLowerCase() + .includes(feedUrl.toLowerCase())) { + let key = json.configuration.packageSources.add['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + } + else { + // file has 2+ + for (let i = 0; i < json.configuration.packageSources.add.length; i++) { + const source = json.configuration.packageSources.add[i]; + const value = source['@_value']; + core.debug(`source '${value}'`); + if (value.toLowerCase().includes(feedUrl.toLowerCase())) { + let key = source['@_key']; + sourceKeys.push(key); + core.debug(`Found a URL with key ${key}`); + } + } + } + } + } + } + xml = xmlbuilder + .create('configuration') + .ele('config') + .ele('add', { key: 'defaultPushSource', value: sourceUrl }) + .up() + .up(); + if (sourceKeys.length == 0) { + let keystring = 'Source'; + xml = xml + .ele('packageSources') + .ele('add', { key: keystring, value: sourceUrl }) + .up() + .up(); + sourceKeys.push(keystring); + } + xml = xml.ele('packageSourceCredentials'); + sourceKeys.forEach(key => { + if (key.indexOf(' ') > -1) { + throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."); + } + xml = xml + .ele(key) + .ele('add', { key: 'Username', value: owner }) + .up() + .ele('add', { + key: 'ClearTextPassword', + value: process.env.NUGET_AUTH_TOKEN + }) + .up() + .up(); + }); + // If NuGet fixes itself such that on Linux it can look for environment variables in the config file (it doesn't seem to work today), + // use this for the value above + // process.platform == 'win32' + // ? '%NUGET_AUTH_TOKEN%' + // : '$NUGET_AUTH_TOKEN' + var output = xml.end({ pretty: true }); + fs.writeFileSync(tempFileLocation, output); +} /***/ }), @@ -7832,83 +7832,83 @@ module.exports = require("assert"); /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.run = void 0; -const core = __importStar(__webpack_require__(470)); -const installer = __importStar(__webpack_require__(749)); -const fs = __importStar(__webpack_require__(747)); -const path = __importStar(__webpack_require__(622)); -const auth = __importStar(__webpack_require__(202)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - // - // dotnet-version is optional, but needs to be provided for most use cases. - // If supplied, install / use from the tool cache. - // If not supplied, look for version in ./global.json. - // If a valid version still can't be identified, nothing will be installed. - // Proxy, auth, (etc) are still set up, even if no version is identified - // - let version = core.getInput('dotnet-version'); - if (!version) { - // Try to fall back to global.json - core.debug('No version found, trying to find version from global.json'); - const globalJsonPath = path.join(process.cwd(), 'global.json'); - if (fs.existsSync(globalJsonPath)) { - const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' })); - if (globalJson.sdk && globalJson.sdk.version) { - version = globalJson.sdk.version; - } - } - } - if (version) { - const dotnetInstaller = new installer.DotnetCoreInstaller(version); - yield dotnetInstaller.installDotnet(); - } - const sourceUrl = core.getInput('source-url'); - const configFile = core.getInput('config-file'); - if (sourceUrl) { - auth.configAuthentication(sourceUrl, configFile); - } - const matchersPath = path.join(__dirname, '..', '.github'); - console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -run(); + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.run = void 0; +const core = __importStar(__webpack_require__(470)); +const installer = __importStar(__webpack_require__(749)); +const fs = __importStar(__webpack_require__(747)); +const path = __importStar(__webpack_require__(622)); +const auth = __importStar(__webpack_require__(202)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + // + // dotnet-version is optional, but needs to be provided for most use cases. + // If supplied, install / use from the tool cache. + // If not supplied, look for version in ./global.json. + // If a valid version still can't be identified, nothing will be installed. + // Proxy, auth, (etc) are still set up, even if no version is identified + // + let version = core.getInput('dotnet-version'); + if (!version) { + // Try to fall back to global.json + core.debug('No version found, trying to find version from global.json'); + const globalJsonPath = path.join(process.cwd(), 'global.json'); + if (fs.existsSync(globalJsonPath)) { + const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' })); + if (globalJson.sdk && globalJson.sdk.version) { + version = globalJson.sdk.version; + } + } + } + if (version) { + const dotnetInstaller = new installer.DotnetCoreInstaller(version); + yield dotnetInstaller.installDotnet(); + } + const sourceUrl = core.getInput('source-url'); + const configFile = core.getInput('config-file'); + if (sourceUrl) { + auth.configAuthentication(sourceUrl, configFile); + } + const matchersPath = path.join(__dirname, '..', '.github'); + console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +run(); /***/ }), @@ -9214,7 +9214,7 @@ function escapeProperty(s) { }; - + // DOM level 1 Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { get: function() { @@ -11012,7 +11012,7 @@ exports.FetchError = FetchError; document(doc, options) { var child, i, j, k, len1, len2, ref, ref1, results; ref = doc.children; - // set a flag so that we don't insert a newline after the last root level node + // set a flag so that we don't insert a newline after the last root level node for (i = j = 0, len1 = ref.length; j < len1; i = ++j) { child = ref[i]; child.isLastRootNode = i === doc.children.length - 1; @@ -12087,14 +12087,14 @@ function authenticationBeforeRequest (state, options) { } else { this.writerOptions.state = WriterState.OpenTag; chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ' 3) - this.throwInvalidVersionFormat(); - if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { - this.throwInvalidVersionFormat(); - } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor = this.getVersionNumberOrThrow(parts[1]); - this.fullversion = major + '.' + minor; - } - getVersionNumberOrThrow(input) { - try { - if (!input || input.trim() === '') - this.throwInvalidVersionFormat(); - let number = Number(input); - if (Number.isNaN(number) || number < 0) - this.throwInvalidVersionFormat(); - return number; - } - catch (_a) { - this.throwInvalidVersionFormat(); - return -1; - } - } - throwInvalidVersionFormat() { - throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; - } - /** - * If true exacatly one version should be resolved - */ - isExactVersion() { - return this.isExactVersionSet; - } - version() { - return this.fullversion; - } -} -exports.DotNetVersionInfo = DotNetVersionInfo; -/** - * Represents a resolved version from the Web-Api - */ -class ResolvedVersionInfo { - constructor(downloadUrls, resolvedVersion) { - if (downloadUrls.length === 0) { - throw 'DownloadUrls can not be empty'; - } - if (!resolvedVersion) { - throw 'Resolved version is invalid'; - } - this.downloadUrls = downloadUrls; - this.resolvedVersion = resolvedVersion; - } -} -class DotnetCoreInstaller { - constructor(version) { - this.versionInfo = new DotNetVersionInfo(version); - this.cachedToolName = 'dncs'; - this.arch = 'x64'; - } - installDotnet() { - return __awaiter(this, void 0, void 0, function* () { - // Check cache - let toolPath = ''; - let osSuffixes = yield this.detectMachineOS(); - let parts = osSuffixes[0].split('-'); - if (parts.length > 1) { - this.arch = parts[1]; - } - // If version is not generic -> look up cache - if (this.versionInfo.isExactVersion()) - toolPath = this.getLocalTool(this.versionInfo.version()); - if (!toolPath) { - // download, extract, cache - console.log('Getting a download url', this.versionInfo.version()); - let resolvedVersionInfo = yield this.resolveInfos(osSuffixes, this.versionInfo); - //Check if cache exists for resolved version - toolPath = this.getLocalTool(resolvedVersionInfo.resolvedVersion); - if (!toolPath) { - //If not exists install it - toolPath = yield this.downloadAndInstall(resolvedVersionInfo); - } - else { - console.log('Using cached tool'); - } - } - else { - console.log('Using cached tool'); - } - // Need to set this so that .NET Core global tools find the right locations. - core.exportVariable('DOTNET_ROOT', toolPath); - // Prepend the tools path. instructs the agent to prepend for future tasks - core.addPath(toolPath); - }); - } - getLocalTool(version) { - console.log('Checking tool cache', version); - return tc.find(this.cachedToolName, version, this.arch); - } - detectMachineOS() { - return __awaiter(this, void 0, void 0, function* () { - let osSuffix = []; - let output = ''; - let resultCode = 0; - if (IS_WINDOWS) { - let escapedScript = path - .join(__dirname, '..', 'externals', 'get-os-platform.ps1') - .replace(/'/g, "''"); - let command = `& '${escapedScript}'`; - const powershellPath = yield io.which('powershell', true); - resultCode = yield exec.exec(`"${powershellPath}"`, [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - } - else { - let scriptPath = path.join(__dirname, '..', 'externals', 'get-os-distro.sh'); - fs_1.chmodSync(scriptPath, '777'); - const toolPath = yield io.which(scriptPath, true); - resultCode = yield exec.exec(`"${toolPath}"`, [], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - } - if (resultCode != 0) { - throw `Failed to detect os with result code ${resultCode}. Output: ${output}`; - } - let index; - if ((index = output.indexOf('Primary:')) >= 0) { - let primary = output.substr(index + 'Primary:'.length).split(os.EOL)[0]; - osSuffix.push(primary); - } - if ((index = output.indexOf('Legacy:')) >= 0) { - let legacy = output.substr(index + 'Legacy:'.length).split(os.EOL)[0]; - osSuffix.push(legacy); - } - if (osSuffix.length == 0) { - throw 'Could not detect platform'; - } - return osSuffix; - }); - } - downloadAndInstall(resolvedVersionInfo) { - return __awaiter(this, void 0, void 0, function* () { - let downloaded = false; - let downloadPath = ''; - for (const url of resolvedVersionInfo.downloadUrls) { - try { - downloadPath = yield tc.downloadTool(url); - downloaded = true; - break; - } - catch (error) { - console.log('Could not Download', url, JSON.stringify(error)); - } - } - if (!downloaded) { - throw 'Failed to download package'; - } - // extract - console.log('Extracting Package', downloadPath); - let extPath = IS_WINDOWS - ? yield tc.extractZip(downloadPath) - : yield tc.extractTar(downloadPath); - // cache tool - console.log('Caching tool'); - let cachedDir = yield tc.cacheDir(extPath, this.cachedToolName, resolvedVersionInfo.resolvedVersion, this.arch); - console.log('Successfully installed', resolvedVersionInfo.resolvedVersion); - return cachedDir; - }); - } - // OsSuffixes - The suffix which is a part of the file name ex- linux-x64, windows-x86 - // Type - SDK / Runtime - // versionInfo - versionInfo of the SDK/Runtime - resolveInfos(osSuffixes, versionInfo) { - return __awaiter(this, void 0, void 0, function* () { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - const releasesJsonUrl = yield this.getReleasesJsonUrl(httpClient, versionInfo.version().split('.')); - const releasesResponse = yield httpClient.getJson(releasesJsonUrl); - const releasesResult = releasesResponse.result || {}; - let releasesInfo = releasesResult['releases']; - releasesInfo = releasesInfo.filter((releaseInfo) => { - return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version()) || - semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version())); - }); - // Exclude versions that are newer than the latest if using not exact - if (!versionInfo.isExactVersion()) { - let latestSdk = releasesResult['latest-sdk']; - releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk)); - } - // Sort for latest version - releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); - let downloadedVersion = ''; - let downloadUrls = []; - if (releasesInfo.length != 0) { - let release = releasesInfo[0]; - downloadedVersion = release['sdk']['version']; - let files = release['sdk']['files']; - files = files.filter((file) => { - if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) { - return (file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz')); - } - }); - if (files.length > 0) { - files.forEach((file) => { - downloadUrls.push(file['url']); - }); - } - else { - throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`; - } - } - else { - console.log(`Could not fetch download information for version ${versionInfo.version()}`); - if (versionInfo.isExactVersion()) { - console.log('Using fallback'); - downloadUrls = yield this.getFallbackDownloadUrls(versionInfo.version()); - downloadedVersion = versionInfo.version(); - } - else { - console.log('Unable to use fallback, version is generic!'); - } - } - if (downloadUrls.length == 0) { - throw `Could not construct download URL. Please ensure that specified version ${versionInfo.version()}/${downloadedVersion} is valid.`; - } - core.debug(`Got download urls ${downloadUrls}`); - return new ResolvedVersionInfo(downloadUrls, downloadedVersion); - }); - } - getReleasesJsonUrl(httpClient, versionParts) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield httpClient.getJson(DotNetCoreIndexUrl); - const result = response.result || {}; - let releasesInfo = result['releases-index']; - releasesInfo = releasesInfo.filter((info) => { - // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x. - const sdkParts = info['channel-version'].split('.'); - if (versionParts.length >= 2 && versionParts[1] != 'x') { - return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1]; - } - return versionParts[0] == sdkParts[0]; - }); - if (releasesInfo.length === 0) { - throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; - } - return releasesInfo[0]['releases.json']; - }); - } - getFallbackDownloadUrls(version) { - return __awaiter(this, void 0, void 0, function* () { - let primaryUrlSearchString; - let legacyUrlSearchString; - let output = ''; - let resultCode = 0; - if (IS_WINDOWS) { - let escapedScript = path - .join(__dirname, '..', 'externals', 'install-dotnet.ps1') - .replace(/'/g, "''"); - let command = `& '${escapedScript}' -Version ${version} -DryRun`; - const powershellPath = yield io.which('powershell', true); - resultCode = yield exec.exec(`"${powershellPath}"`, [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; - legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; - } - else { - let escapedScript = path - .join(__dirname, '..', 'externals', 'install-dotnet.sh') - .replace(/'/g, "''"); - fs_1.chmodSync(escapedScript, '777'); - const scriptPath = yield io.which(escapedScript, true); - resultCode = yield exec.exec(`"${scriptPath}"`, ['--version', version, '--dry-run'], { - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }); - primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; - legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; - } - if (resultCode != 0) { - throw `Failed to get download urls with result code ${resultCode}. ${output}`; - } - let primaryUrl = ''; - let legacyUrl = ''; - if (!!output && output.length > 0) { - let lines = output.split(os.EOL); - // Fallback to \n if initial split doesn't work (not consistent across versions) - if (lines.length === 1) { - lines = output.split('\n'); - } - if (!!lines && lines.length > 0) { - lines.forEach((line) => { - if (!line) { - return; - } - var primarySearchStringIndex = line.indexOf(primaryUrlSearchString); - if (primarySearchStringIndex > -1) { - primaryUrl = line.substring(primarySearchStringIndex + primaryUrlSearchString.length); - return; - } - var legacySearchStringIndex = line.indexOf(legacyUrlSearchString); - if (legacySearchStringIndex > -1) { - legacyUrl = line.substring(legacySearchStringIndex + legacyUrlSearchString.length); - return; - } - }); - } - } - return [primaryUrl, legacyUrl]; - }); - } -} -exports.DotnetCoreInstaller = DotnetCoreInstaller; -const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DotnetCoreInstaller = exports.DotNetVersionInfo = void 0; +// Load tempDirectory before it gets wiped by tool-cache +let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''; +const core = __importStar(__webpack_require__(470)); +const exec = __importStar(__webpack_require__(986)); +const io = __importStar(__webpack_require__(1)); +const tc = __importStar(__webpack_require__(533)); +const hc = __webpack_require__(539); +const fs_1 = __webpack_require__(747); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); +const semver = __importStar(__webpack_require__(280)); +const IS_WINDOWS = process.platform === 'win32'; +if (!tempDirectory) { + let baseLocation; + if (IS_WINDOWS) { + // On windows use the USERPROFILE env variable + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } + else { + if (process.platform === 'darwin') { + baseLocation = '/Users'; + } + else { + baseLocation = '/home'; + } + } + tempDirectory = path.join(baseLocation, 'actions', 'temp'); +} +/** + * Represents the inputted version information + */ +class DotNetVersionInfo { + constructor(version) { + this.isExactVersionSet = false; + // Check for exact match + if (semver.valid(semver.clean(version) || '') != null) { + this.fullversion = semver.clean(version); + this.isExactVersionSet = true; + return; + } + //Note: No support for previews when using generic + let parts = version.split('.'); + if (parts.length < 2 || parts.length > 3) + this.throwInvalidVersionFormat(); + if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { + this.throwInvalidVersionFormat(); + } + let major = this.getVersionNumberOrThrow(parts[0]); + let minor = this.getVersionNumberOrThrow(parts[1]); + this.fullversion = major + '.' + minor; + } + getVersionNumberOrThrow(input) { + try { + if (!input || input.trim() === '') + this.throwInvalidVersionFormat(); + let number = Number(input); + if (Number.isNaN(number) || number < 0) + this.throwInvalidVersionFormat(); + return number; + } + catch (_a) { + this.throwInvalidVersionFormat(); + return -1; + } + } + throwInvalidVersionFormat() { + throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; + } + /** + * If true exacatly one version should be resolved + */ + isExactVersion() { + return this.isExactVersionSet; + } + version() { + return this.fullversion; + } +} +exports.DotNetVersionInfo = DotNetVersionInfo; +/** + * Represents a resolved version from the Web-Api + */ +class ResolvedVersionInfo { + constructor(downloadUrls, resolvedVersion) { + if (downloadUrls.length === 0) { + throw 'DownloadUrls can not be empty'; + } + if (!resolvedVersion) { + throw 'Resolved version is invalid'; + } + this.downloadUrls = downloadUrls; + this.resolvedVersion = resolvedVersion; + } +} +class DotnetCoreInstaller { + constructor(version) { + this.versionInfo = new DotNetVersionInfo(version); + this.cachedToolName = 'dncs'; + this.arch = 'x64'; + } + installDotnet() { + return __awaiter(this, void 0, void 0, function* () { + // Check cache + let toolPath = ''; + let osSuffixes = yield this.detectMachineOS(); + let parts = osSuffixes[0].split('-'); + if (parts.length > 1) { + this.arch = parts[1]; + } + // If version is not generic -> look up cache + if (this.versionInfo.isExactVersion()) + toolPath = this.getLocalTool(this.versionInfo.version()); + if (!toolPath) { + // download, extract, cache + console.log('Getting a download url', this.versionInfo.version()); + let resolvedVersionInfo = yield this.resolveInfos(osSuffixes, this.versionInfo); + //Check if cache exists for resolved version + toolPath = this.getLocalTool(resolvedVersionInfo.resolvedVersion); + if (!toolPath) { + //If not exists install it + toolPath = yield this.downloadAndInstall(resolvedVersionInfo); + } + else { + console.log('Using cached tool'); + } + } + else { + console.log('Using cached tool'); + } + // Need to set this so that .NET Core global tools find the right locations. + core.exportVariable('DOTNET_ROOT', toolPath); + // Prepend the tools path. instructs the agent to prepend for future tasks + core.addPath(toolPath); + }); + } + getLocalTool(version) { + console.log('Checking tool cache', version); + return tc.find(this.cachedToolName, version, this.arch); + } + detectMachineOS() { + return __awaiter(this, void 0, void 0, function* () { + let osSuffix = []; + let output = ''; + let resultCode = 0; + if (IS_WINDOWS) { + let escapedScript = path + .join(__dirname, '..', 'externals', 'get-os-platform.ps1') + .replace(/'/g, "''"); + let command = `& '${escapedScript}'`; + const powershellPath = yield io.which('powershell', true); + resultCode = yield exec.exec(`"${powershellPath}"`, [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + } + else { + let scriptPath = path.join(__dirname, '..', 'externals', 'get-os-distro.sh'); + fs_1.chmodSync(scriptPath, '777'); + const toolPath = yield io.which(scriptPath, true); + resultCode = yield exec.exec(`"${toolPath}"`, [], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + } + if (resultCode != 0) { + throw `Failed to detect os with result code ${resultCode}. Output: ${output}`; + } + let index; + if ((index = output.indexOf('Primary:')) >= 0) { + let primary = output.substr(index + 'Primary:'.length).split(os.EOL)[0]; + osSuffix.push(primary); + } + if ((index = output.indexOf('Legacy:')) >= 0) { + let legacy = output.substr(index + 'Legacy:'.length).split(os.EOL)[0]; + osSuffix.push(legacy); + } + if (osSuffix.length == 0) { + throw 'Could not detect platform'; + } + return osSuffix; + }); + } + downloadAndInstall(resolvedVersionInfo) { + return __awaiter(this, void 0, void 0, function* () { + let downloaded = false; + let downloadPath = ''; + for (const url of resolvedVersionInfo.downloadUrls) { + try { + downloadPath = yield tc.downloadTool(url); + downloaded = true; + break; + } + catch (error) { + console.log('Could not Download', url, JSON.stringify(error)); + } + } + if (!downloaded) { + throw 'Failed to download package'; + } + // extract + console.log('Extracting Package', downloadPath); + let extPath = IS_WINDOWS + ? yield tc.extractZip(downloadPath) + : yield tc.extractTar(downloadPath); + // cache tool + console.log('Caching tool'); + let cachedDir = yield tc.cacheDir(extPath, this.cachedToolName, resolvedVersionInfo.resolvedVersion, this.arch); + console.log('Successfully installed', resolvedVersionInfo.resolvedVersion); + return cachedDir; + }); + } + // OsSuffixes - The suffix which is a part of the file name ex- linux-x64, windows-x86 + // Type - SDK / Runtime + // versionInfo - versionInfo of the SDK/Runtime + resolveInfos(osSuffixes, versionInfo) { + return __awaiter(this, void 0, void 0, function* () { + const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { + allowRetries: true, + maxRetries: 3 + }); + const releasesJsonUrl = yield this.getReleasesJsonUrl(httpClient, versionInfo.version().split('.')); + const releasesResponse = yield httpClient.getJson(releasesJsonUrl); + const releasesResult = releasesResponse.result || {}; + let releasesInfo = releasesResult['releases']; + releasesInfo = releasesInfo.filter((releaseInfo) => { + return (semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version()) || + semver.satisfies(releaseInfo['sdk']['version-display'], versionInfo.version())); + }); + // Exclude versions that are newer than the latest if using not exact + if (!versionInfo.isExactVersion()) { + let latestSdk = releasesResult['latest-sdk']; + releasesInfo = releasesInfo.filter((releaseInfo) => semver.lte(releaseInfo['sdk']['version'], latestSdk)); + } + // Sort for latest version + releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); + let downloadedVersion = ''; + let downloadUrls = []; + if (releasesInfo.length != 0) { + let release = releasesInfo[0]; + downloadedVersion = release['sdk']['version']; + let files = release['sdk']['files']; + files = files.filter((file) => { + if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) { + return (file['url'].endsWith('.zip') || file['url'].endsWith('.tar.gz')); + } + }); + if (files.length > 0) { + files.forEach((file) => { + downloadUrls.push(file['url']); + }); + } + else { + throw `The specified version's download links are not correctly formed in the supported versions document => ${releasesJsonUrl}`; + } + } + else { + console.log(`Could not fetch download information for version ${versionInfo.version()}`); + if (versionInfo.isExactVersion()) { + console.log('Using fallback'); + downloadUrls = yield this.getFallbackDownloadUrls(versionInfo.version()); + downloadedVersion = versionInfo.version(); + } + else { + console.log('Unable to use fallback, version is generic!'); + } + } + if (downloadUrls.length == 0) { + throw `Could not construct download URL. Please ensure that specified version ${versionInfo.version()}/${downloadedVersion} is valid.`; + } + core.debug(`Got download urls ${downloadUrls}`); + return new ResolvedVersionInfo(downloadUrls, downloadedVersion); + }); + } + getReleasesJsonUrl(httpClient, versionParts) { + return __awaiter(this, void 0, void 0, function* () { + const response = yield httpClient.getJson(DotNetCoreIndexUrl); + const result = response.result || {}; + let releasesInfo = result['releases-index']; + releasesInfo = releasesInfo.filter((info) => { + // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x. + const sdkParts = info['channel-version'].split('.'); + if (versionParts.length >= 2 && versionParts[1] != 'x') { + return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1]; + } + return versionParts[0] == sdkParts[0]; + }); + if (releasesInfo.length === 0) { + throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; + } + return releasesInfo[0]['releases.json']; + }); + } + getFallbackDownloadUrls(version) { + return __awaiter(this, void 0, void 0, function* () { + let primaryUrlSearchString; + let legacyUrlSearchString; + let output = ''; + let resultCode = 0; + if (IS_WINDOWS) { + let escapedScript = path + .join(__dirname, '..', 'externals', 'install-dotnet.ps1') + .replace(/'/g, "''"); + let command = `& '${escapedScript}' -Version ${version} -DryRun`; + const powershellPath = yield io.which('powershell', true); + resultCode = yield exec.exec(`"${powershellPath}"`, [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; + legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; + } + else { + let escapedScript = path + .join(__dirname, '..', 'externals', 'install-dotnet.sh') + .replace(/'/g, "''"); + fs_1.chmodSync(escapedScript, '777'); + const scriptPath = yield io.which(escapedScript, true); + resultCode = yield exec.exec(`"${scriptPath}"`, ['--version', version, '--dry-run'], { + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }); + primaryUrlSearchString = 'dotnet-install: Primary named payload URL: '; + legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: '; + } + if (resultCode != 0) { + throw `Failed to get download urls with result code ${resultCode}. ${output}`; + } + let primaryUrl = ''; + let legacyUrl = ''; + if (!!output && output.length > 0) { + let lines = output.split(os.EOL); + // Fallback to \n if initial split doesn't work (not consistent across versions) + if (lines.length === 1) { + lines = output.split('\n'); + } + if (!!lines && lines.length > 0) { + lines.forEach((line) => { + if (!line) { + return; + } + var primarySearchStringIndex = line.indexOf(primaryUrlSearchString); + if (primarySearchStringIndex > -1) { + primaryUrl = line.substring(primarySearchStringIndex + primaryUrlSearchString.length); + return; + } + var legacySearchStringIndex = line.indexOf(legacyUrlSearchString); + if (legacySearchStringIndex > -1) { + legacyUrl = line.substring(legacySearchStringIndex + legacyUrlSearchString.length); + return; + } + }); + } + } + return [primaryUrl, legacyUrl]; + }); + } +} +exports.DotnetCoreInstaller = DotnetCoreInstaller; +const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; /***/ }), @@ -20963,7 +20963,7 @@ module.exports = set; return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); } - + // Returns debug string for this node debugInfo(name) { name = name || this.name; @@ -21777,7 +21777,7 @@ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, module.exports = XMLDummy = class XMLDummy extends XMLNode { // Initializes a new instance of `XMLDummy` - // `XMLDummy` is a special node representing a node with + // `XMLDummy` is a special node representing a node with // a null value. Dummy nodes are created while recursively // building the XML tree. Simply skipping null values doesn't // work because that would break the recursive chain. @@ -22503,7 +22503,7 @@ const validator = __webpack_require__(971); exports.parse = function(xmlData, options, validationOption) { if( validationOption){ if(validationOption === true) validationOption = {} - + const result = validator.validate(xmlData, validationOption); if (result !== true) { throw Error( result.err.msg)