Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
const desugaredversion = desugarDevVersion(parameters.version);
const semanticversion: string = pythonVersionToSemantic(desugaredversion);
task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);
const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);
console.log('INSTALL DIR - ' + installDir);
if (!installDir) {
// Fail and list available versions
const x86Versions = tool.findLocalToolVersions('Python', 'x86')
.map(s => `${s} (x86)`)
.join(os.EOL);
const x64Versions = tool.findLocalToolVersions('Python', 'x64')
.map(s => `${s} (x64)`)
.join(os.EOL);
throw new Error([
task.loc('VersionNotFound', parameters.version, parameters.architecture),
task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
console.log('yuniql/input_additionalArguments: ' + additionalArguments);
console.log('yuniql/var_osPlat: ' + osPlat);
console.log('yuniql/var_osArch: ' + osArch);
//picksup the version downloaded from install task
let versionLocation: string = '';
if (toolLib.isExplicitVersion(versionSpec)) {
versionLocation = versionSpec;
} else {
//use v0.0.0 as placeholder for latest version
versionLocation = 'v0.0.0'
}
if (osPlat == 'win32') {
var yuniqlBasePath = path.join(toolLib.findLocalTool('yuniql', versionLocation));
console.log('yuniql/var_yuniqlBasePath: ' + yuniqlBasePath);
var yuniqlExecFilePath = path.join(yuniqlBasePath, 'yuniql.exe');
console.log('yuniql/var_yuniqlExecFilePath: ' + yuniqlExecFilePath);
//set the plugin path
// var pluginsPath = path.join(yuniqlBasePath, '.plugins');
// console.log('var_pluginsPath: ' + pluginsPath);
//builds up the arguments structure
let yuniql = new tr.ToolRunner(yuniqlExecFilePath);
yuniql.arg('run');
// yuniql.arg('--plugins-path');
// yuniql.arg(pluginsPath);
console.log(tl.loc("ToolToInstall", packageType, versionSpec));
var versionSpecParts = new VersionParts(versionSpec);
let versionFetcher = new DotNetCoreVersionFetcher();
let versionInfo: VersionInfo = await versionFetcher.getVersionInfo(versionSpecParts.versionSpec, packageType, includePreviewVersions);
if (!versionInfo) {
throw tl.loc("MatchingVersionNotFound", versionSpecParts.versionSpec);
}
let dotNetCoreInstaller = new VersionInstaller(packageType, installationPath);
if (!dotNetCoreInstaller.isVersionInstalled(versionInfo.getVersion())) {
await dotNetCoreInstaller.downloadAndInstall(versionInfo, versionFetcher.getDownloadUrl(versionInfo));
}
toolLib.prependPath(installationPath);
// By default disable Multi Level Lookup unless user wants it enabled.
let performMultiLevelLookup = tl.getBoolInput("performMultiLevelLookup", false);
tl.setVariable("DOTNET_MULTILEVEL_LOOKUP", !performMultiLevelLookup ? "0" : "1");
// Add dot net tools path to "PATH" environment variables, so that tools can be used directly.
addDotNetCoreToolPath();
// Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
tl.setVariable('DOTNET_ROOT', installationPath);
}
public async downloadAndInstall(versionInfo: VersionInfo, downloadUrl: string): Promise {
if (!versionInfo || !versionInfo.getVersion() || !downloadUrl || !url.parse(downloadUrl)) {
throw tl.loc("VersionCanNotBeDownloadedFromUrl", versionInfo, downloadUrl);
}
let version = versionInfo.getVersion();
try {
try {
var downloadPath = await toolLib.downloadTool(downloadUrl)
}
catch (ex) {
throw tl.loc("CouldNotDownload", downloadUrl, ex);
}
// Extract
console.log(tl.loc("ExtractingPackage", downloadPath));
try {
var extPath = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
}
catch (ex) {
throw tl.loc("FailedWhileExtractingPacakge", ex);
}
// Copy folders
tl.debug(tl.loc("CopyingFoldersIntoPath", this.installationPath));
}
let version = versionInfo.getVersion();
try {
try {
var downloadPath = await toolLib.downloadTool(downloadUrl)
}
catch (ex) {
throw tl.loc("CouldNotDownload", downloadUrl, ex);
}
// Extract
console.log(tl.loc("ExtractingPackage", downloadPath));
try {
var extPath = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
}
catch (ex) {
throw tl.loc("FailedWhileExtractingPacakge", ex);
}
// Copy folders
tl.debug(tl.loc("CopyingFoldersIntoPath", this.installationPath));
var allRootLevelEnteriesInDir: string[] = tl.ls("", [extPath]).map(name => path.join(extPath, name));
var directoriesTobeCopied: string[] = allRootLevelEnteriesInDir.filter(path => fs.lstatSync(path).isDirectory());
directoriesTobeCopied.forEach((directoryPath) => {
tl.cp(directoryPath, this.installationPath, "-rf", false);
});
// Copy files
try {
if (this.packageType == utils.Constants.sdk && this.isLatestInstalledVersion(version)) {
throw tl.loc("VersionCanNotBeDownloadedFromUrl", versionInfo, downloadUrl);
}
let version = versionInfo.getVersion();
try {
try {
var downloadPath = await toolLib.downloadTool(downloadUrl)
}
catch (ex) {
throw tl.loc("CouldNotDownload", downloadUrl, ex);
}
// Extract
console.log(tl.loc("ExtractingPackage", downloadPath));
try {
var extPath = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
}
catch (ex) {
throw tl.loc("FailedWhileExtractingPacakge", ex);
}
// Copy folders
tl.debug(tl.loc("CopyingFoldersIntoPath", this.installationPath));
var allRootLevelEnteriesInDir: string[] = tl.ls("", [extPath]).map(name => path.join(extPath, name));
var directoriesTobeCopied: string[] = allRootLevelEnteriesInDir.filter(path => fs.lstatSync(path).isDirectory());
directoriesTobeCopied.forEach((directoryPath) => {
tl.cp(directoryPath, this.installationPath, "-rf", false);
});
// Copy files
try {
if (this.packageType == utils.Constants.sdk && this.isLatestInstalledVersion(version)) {
console.log('yuniql/input_version: ' + versionSpec);
console.log('yuniql/input_workspacePath: ' + workspacePath);
console.log('yuniql/input_connectionString: ' + connectionString);
console.log('yuniql/input_targetPlatform: ' + targetPlatform);
console.log('yuniql/input_autoCreateDatabase: ' + autoCreateDatabase);
console.log('yuniql/input_targetVersion: ' + targetVersion);
console.log('yuniql/input_tokenKeyValuePair: ' + tokenKeyValuePair);
console.log('yuniql/input_delimiter: ' + delimiter);
console.log('yuniql/input_additionalArguments: ' + additionalArguments);
console.log('yuniql/var_osPlat: ' + osPlat);
console.log('yuniql/var_osArch: ' + osArch);
//picksup the version downloaded from install task
let versionLocation: string = '';
if (toolLib.isExplicitVersion(versionSpec)) {
versionLocation = versionSpec;
} else {
//use v0.0.0 as placeholder for latest version
versionLocation = 'v0.0.0'
}
if (osPlat == 'win32') {
var yuniqlBasePath = path.join(toolLib.findLocalTool('yuniql', versionLocation));
console.log('yuniql/var_yuniqlBasePath: ' + yuniqlBasePath);
var yuniqlExecFilePath = path.join(yuniqlBasePath, 'yuniql.exe');
console.log('yuniql/var_yuniqlExecFilePath: ' + yuniqlExecFilePath);
//set the plugin path
// var pluginsPath = path.join(yuniqlBasePath, '.plugins');
// console.log('var_pluginsPath: ' + pluginsPath);
export async function getYuniql(versionSpec: string, checkLatest: boolean) {
try {
console.log('yuniql/var_osPlat: ' + osPlat);
console.log('yuniql/var_osArch: ' + osArch);
// when version is explicit, we dont check the latest
let version: string = '';
if (toolLib.isExplicitVersion(versionSpec)) {
checkLatest = false;
console.log('yuniql/var_isExplicitVersion: true');
console.log('yuniql/var_checkLatest: false');
}
// when version is explicit, we check the cache first
let toolPath: string = '';
if (!checkLatest) {
toolPath = toolLib.findLocalTool('yuniql', versionSpec);
}
// when cached version doesnt exists, we download a fresh copy
if (!toolPath) {
//when version is explicit, use the version specified, else we acquire latest version
if (toolLib.isExplicitVersion(versionSpec)) {
version = versionSpec;
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
const desugaredversion = desugarDevVersion(parameters.version);
const semanticversion: string = pythonVersionToSemantic(desugaredversion);
task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);
const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);
console.log('INSTALL DIR - ' + installDir);
if (!installDir) {
// Fail and list available versions
const x86Versions = tool.findLocalToolVersions('Python', 'x86')
.map(s => `${s} (x86)`)
.join(os.EOL);
const x64Versions = tool.findLocalToolVersions('Python', 'x64')
.map(s => `${s} (x64)`)
.join(os.EOL);
throw new Error([
task.loc('VersionNotFound', parameters.version, parameters.architecture),
task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
x86Versions,
x64Versions,
task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
].join(os.EOL));
}
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
const desugaredversion = desugarDevVersion(parameters.version);
const semanticversion: string = pythonVersionToSemantic(desugaredversion);
task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);
const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);
console.log('INSTALL DIR - ' + installDir);
if (!installDir) {
// Fail and list available versions
const x86Versions = tool.findLocalToolVersions('Python', 'x86')
.map(s => `${s} (x86)`)
.join(os.EOL);
const x64Versions = tool.findLocalToolVersions('Python', 'x64')
.map(s => `${s} (x64)`)
.join(os.EOL);
throw new Error([
task.loc('VersionNotFound', parameters.version, parameters.architecture),
task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
x86Versions,
x64Versions,
task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
].join(os.EOL));
}
task.setVariable('pythonLocation', installDir);
// Append to path