Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await ftpClient.ensureDir(ftpOptions.remotePath);
}, tries);
for (const file of files) {
tl.debug("file: " + file);
let remoteFile: string = ftpOptions.preservePaths
? path.join(
ftpOptions.remotePath,
file.substring(ftpOptions.rootFolder.length)
)
: path.join(ftpOptions.remotePath, path.basename(file));
remoteFile = remoteFile.replace(/\\/gi, "/"); // always use forward slashes
tl.debug("remoteFile: " + remoteFile);
let stats = tl.stats(file);
if (stats.isDirectory()) {
await retryWithNewClient(async () => {
await ftpClient.ensureDir(remoteFile);
}, tries);
tracker.directoryProcessed(remoteFile);
} else if (stats.isFile()) {
// upload files
await retryWithNewClient(async () => {
await ftpClient.upload(fs.createReadStream(file), remoteFile);
}, tries);
tracker.fileUploaded(file, remoteFile);
}
}
console.log(tl.loc("UploadSucceedMsg", tracker.getSuccessStatusMessage()));
} catch (err) {
function findFiles(ftpOptions: FtpOptions): string[] {
tl.debug("Searching for files to upload");
try {
const rootFolderStats = tl.stats(ftpOptions.rootFolder);
if (rootFolderStats.isFile()) {
const file = ftpOptions.rootFolder;
tl.debug(file + " is a file. Ignoring all file patterns");
return [file];
}
const allFiles = tl.find(ftpOptions.rootFolder);
// filePatterns is a multiline input containing glob patterns
tl.debug(
"searching for files using: " +
ftpOptions.filePatterns.length +
" filePatterns: " +
ftpOptions.filePatterns
);
let advisorPath = yield advisordownloader.DownloadAdvisor();
// Construct the CLI.
//let advisorPath: string = tl.which('advisor', true);
let advisorCli = tl.tool(advisorPath);
advisorCli.arg(["--eula-sign", "validate", "cluster"]);
advisorCli.arg(['--cluster-context', getClusterContextName(tl.getInput("connectionType", true))]);
if (tl.getBoolInput('failOnCritical', false)) {
advisorCli.arg(["--run-mode", "pipeline"]);
}
let advisorScanReportFormat = tl.getInput('advisorScanReportFormat', false);
if ((advisorScanReportFormat != null) && (advisorScanReportFormat != undefined) && (advisorScanReportFormat != '') && (advisorScanReportFormat == 'excel')) {
advisorCli.arg(["--output", "excel"]);
}
let advisorProfile = tl.getInput('advisorProfile', false);
if (advisorProfile != null && advisorProfile != undefined && advisorProfile != '') {
if (tl.stats(advisorProfile).isFile()) {
advisorCli.arg(['--policy-profile', advisorProfile]);
let alcideApiKey = tl.getInput('alcideApiKey', false);
if (alcideApiKey != null && alcideApiKey != undefined && alcideApiKey != '') {
advisorCli.arg(["--alcide-api-key", alcideApiKey]);
}
else {
tl.warning("Advisor Api Key is missing ");
}
let alcideApiServer = tl.getInput('alcideApiServer', false);
if (alcideApiServer != null && alcideApiServer != undefined && alcideApiServer != '') {
advisorCli.arg(["--alcide-api-server", alcideApiServer]);
}
else {
tl.warning("Advisor Api Server is missing ");
}
}
for (const imageType of imageTypes) {
let shouldAttemptUpload: boolean = false;
imageList[imageType] = [];
tl.debug(`Attempting to get images of type ${imageType}`);
switch (imageType) {
case 'featureGraphic':
case 'icon':
case 'promoGraphic':
case 'tvBanner':
for (let acceptedExtension of acceptedExtensions) {
let fullPathToFileToCheck: string = path.join(imageDirectory, imageType + acceptedExtension);
try {
let imageStat: tl.FsStats = tl.stats(fullPathToFileToCheck);
if (imageStat) {
shouldAttemptUpload = imageStat.isFile();
if (shouldAttemptUpload) {
console.log(tl.loc('FoundImageAtPath', imageType, fullPathToFileToCheck));
imageList[imageType].push(fullPathToFileToCheck);
break;
}
}
} catch (e) {
tl.debug(`File ${fullPathToFileToCheck} doesn't exist. Skipping...`);
}
}
if (!shouldAttemptUpload) {
console.log(tl.loc('ImageTypeNotFound', imageType));
}
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
const authType: string = tl.getInput('authType', true);
let key: googleutil.ClientKey = {};
if (authType === 'JsonFile') {
const serviceAccountKeyFile: string = tl.getPathInput('serviceAccountKey', false);
if (!serviceAccountKeyFile) {
throw new Error(tl.loc('JsonKeyFileNotFound'));
}
const stats: tl.FsStats = tl.stats(serviceAccountKeyFile);
if (stats && stats.isFile()) {
key = require(serviceAccountKeyFile);
} else {
console.error(tl.loc('InvalidAuthFile'));
throw new Error(tl.loc('InvalidAuthFilewithName', serviceAccountKeyFile));
}
} else if (authType === 'ServiceEndpoint') {
const serviceEndpoint: tl.EndpointAuthorization = tl.getEndpointAuthorization(tl.getInput('serviceEndpoint', true), true);
if (!serviceEndpoint) {
throw new Error(tl.loc('EndpointNotFound'));
}
key.client_email = serviceEndpoint.parameters['username'];
key.private_key = serviceEndpoint.parameters['password'].replace(/\\n/g, '\n');
}
const packageName: string = tl.getPathInput('packageName', true);
"/output",
"buildserver",
"/nofetch"]);
if (this.useConfigFile) {
if (tl.filePathSupplied('configFilePath') && tl.exist(this.configFilePath) && tl.stats(this.configFilePath).isFile()) {
exe.arg(["/config", this.configFilePath]);
}
else {
throw new Error('GitVersion configuration file not found at ' + this.configFilePath);
}
}
if (this.updateAssemblyInfo) {
exe.arg("/updateassemblyinfo");
if (tl.filePathSupplied('updateAssemblyInfoFilename') && tl.exist(this.updateAssemblyInfoFilename) && tl.stats(this.updateAssemblyInfoFilename).isFile()) {
exe.arg(this.updateAssemblyInfoFilename);
}
else {
throw new Error('AssemblyInfoFilename file not found at ' + this.updateAssemblyInfoFilename);
}
}
if (this.additionalArguments) {
exe.line(this.additionalArguments);
}
const result = await exe.exec(this.execOptions);
if (result) {
tl.setResult(tl.TaskResult.Failed, "An error occured during GitVersion execution");
} else {
tl.setResult(tl.TaskResult.Succeeded, "GitVersion executed successfully");
const matchedFiles = matchedPaths.filter(itemPath => !tl.stats(itemPath).isDirectory())
tl.debug(tl.loc('MatchedFiles', matchedFiles))
export function directoryExists(path: string) {
try {
return tl.stats(path).isDirectory();
} catch (error) {
tl.debug(`directoryExists(${path}): ${"" + error}`);
return false;
}
}
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
tl.debug('Prepare task inputs.');
const authType: string = tl.getInput('authType', true);
let key: googleutil.ClientKey = {};
if (authType === 'JsonFile') {
const serviceAccountKeyFile: string = tl.getPathInput('serviceAccountKey', true, true);
const stats: tl.FsStats = tl.stats(serviceAccountKeyFile);
if (stats && stats.isFile()) {
key = require(serviceAccountKeyFile);
} else {
tl.debug(`The service account file path ${serviceAccountKeyFile} points to a directory.`);
throw new Error(tl.loc('InvalidAuthFile', serviceAccountKeyFile));
}
} else if (authType === 'ServiceEndpoint') {
let serviceEndpoint: tl.EndpointAuthorization = tl.getEndpointAuthorization(tl.getInput('serviceEndpoint', true), false);
key.client_email = serviceEndpoint.parameters['username'];
key.private_key = serviceEndpoint.parameters['password'].replace(/\\n/g, '\n');
}
const packageName: string = tl.getInput('applicationId', true);
tl.debug(`Application identifier: ${packageName}`);
const mainBundlePattern = tl.getPathInput('bundleFile', true);