本文整理匯總了TypeScript中webdeployment-common/ziputility.js.default.archiveFolder方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.default.archiveFolder方法的具體用法?TypeScript js.default.archiveFolder怎麽用?TypeScript js.default.archiveFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webdeployment-common/ziputility.js.default
的用法示例。
在下文中一共展示了js.default.archiveFolder方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: deployWebPackage
public async deployWebPackage(packagePath: string, physicalPath: string, virtualPath: string, appOffline?: boolean): Promise<void> {
physicalPath = physicalPath ? physicalPath : physicalRootPath;
try {
if(appOffline) {
await this._appOfflineKuduService(physicalPath, true);
tl.debug('Wait for 10 seconds for app_offline to take effect');
await webClient.sleepFor(10);
}
if(tl.stats(packagePath).isDirectory()) {
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
packagePath = await zipUtility.archiveFolder(packagePath, "", tempPackagePath);
tl.debug("Compressed folder " + packagePath + " into zip : " + packagePath);
}
else if(packagePath.toLowerCase().endsWith('.war')) {
physicalPath = await this._warFileDeployment(packagePath, physicalPath, virtualPath);
}
await this._appServiceKuduService.extractZIP(packagePath, physicalPath);
if(appOffline) {
await this._appOfflineKuduService(physicalPath, false);
}
console.log(tl.loc("Successfullydeployedpackageusingkuduserviceat", packagePath, physicalPath));
}
catch(error) {
tl.error(tl.loc('PackageDeploymentFailed'));
throw Error(error);
}
}
示例2: fileTransformations
export async function fileTransformations(isFolderBasedDeployment: boolean, JSONFiles: any, xmlTransformation: boolean, xmlVariableSubstitution: boolean, webDeployPkg: string) {
var tempPackagePath;
var folderPath = utility.generateTemporaryFolderOrZipPath(tl.getVariable('System.DefaultWorkingDirectory'), true);
if(isFolderBasedDeployment) {
tl.cp(path.join(webDeployPkg, '/*'), folderPath, '-rf', false);
}
else {
await zipUtility.unzip(webDeployPkg, folderPath);
}
if(xmlTransformation) {
var environmentName = tl.getVariable('Release.EnvironmentName');
if(tl.osType().match(/^Win/)) {
var transformConfigs = ["Release.config"];
if(environmentName) {
transformConfigs.push(environmentName + ".config");
}
xdtTransformationUtility.basicXdtTransformation(folderPath, transformConfigs);
console.log(tl.loc("XDTTransformationsappliedsuccessfully"));
}
else {
throw new Error(tl.loc("CannotPerformXdtTransformationOnNonWindowsPlatform"));
}
}
if(xmlVariableSubstitution) {
await xmlSubstitutionUtility.substituteAppSettingsVariables(folderPath);
console.log(tl.loc('XMLvariablesubstitutionappliedsuccessfully'));
}
if(JSONFiles.length != 0) {
jsonSubstitutionUtility.jsonVariableSubstitution(folderPath, JSONFiles);
console.log(tl.loc('JSONvariablesubstitutionappliedsuccessfully'));
}
if(isFolderBasedDeployment) {
tempPackagePath = folderPath;
webDeployPkg = folderPath;
}
else {
var tempWebPackageZip = utility.generateTemporaryFolderOrZipPath(tl.getVariable('System.DefaultWorkingDirectory'), false);
webDeployPkg = await zipUtility.archiveFolder(folderPath, "", tempWebPackageZip);
tempPackagePath = webDeployPkg;
tl.rmRF(folderPath, true);
}
return {
"webDeployPkg": webDeployPkg,
"tempPackagePath": tempPackagePath
};
}
示例3: zipDeploy
public async zipDeploy(packagePath: string, appOffline?: boolean, customMessage?: any): Promise<string> {
try {
console.log(tl.loc('PackageDeploymentInitiated'));
await this._preZipDeployOperation();
if(tl.stats(packagePath).isDirectory()) {
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
packagePath = await zipUtility.archiveFolder(packagePath, "", tempPackagePath);
tl.debug("Compressed folder " + packagePath + " into zip : " + packagePath);
}
if(appOffline) {
await this._appOfflineKuduService(physicalRootPath, true);
tl.debug('Wait for 10 seconds for app_offline to take effect');
await webClient.sleepFor(10);
}
let queryParameters: Array<string> = [
'isAsync=true',
'deployer=' + VSTS_ZIP_DEPLOY
];
let deploymentDetails = await this._appServiceKuduService.zipDeploy(packagePath, queryParameters);
try {
var kuduDeploymentDetails = await this._appServiceKuduService.getDeploymentDetails(deploymentDetails.id);
tl.debug(`logs from ZIP deploy: ${kuduDeploymentDetails.log_url}`);
await this._printZipDeployLogs(kuduDeploymentDetails.log_url);
}
catch(error) {
tl.debug(`Unable to fetch logs for kudu ZIP Deploy: ${JSON.stringify(error)}`)
}
if(deploymentDetails.status == KUDU_DEPLOYMENT_CONSTANTS.FAILED) {
throw tl.loc('PackageDeploymentUsingZipDeployFailed');
}
if(appOffline) {
await this._appOfflineKuduService(physicalRootPath, false);
}
console.log(tl.loc('PackageDeploymentSuccess'));
return deploymentDetails.id;
}
catch(error) {
tl.error(tl.loc('PackageDeploymentFailed'));
throw Error(error);
}
}
示例4: archiveFolderForDeployment
export async function archiveFolderForDeployment(isFolderBasedDeployment: boolean, folderPath: string) {
var webDeployPkg;
if(isFolderBasedDeployment) {
webDeployPkg = folderPath;
}
else {
var tempWebPackageZip = generateTemporaryFolderOrZipPath(tl.getVariable('System.DefaultWorkingDirectory'), false);
webDeployPkg = await zipUtility.archiveFolder(folderPath, "", tempWebPackageZip);
}
return {
"webDeployPkg": webDeployPkg,
"tempPackagePath": webDeployPkg
};
}
示例5: DeployWebAppStep
public async DeployWebAppStep() {
let deploymentMethodtelemetry = '{"deploymentMethod":"Zip Deploy"}';
console.log("##vso[telemetry.publish area=TaskDeploymentMethod;feature=AzureWebAppDeployment]" + deploymentMethodtelemetry);
var webPackage = await FileTransformsUtility.applyTransformations(this.taskParams.Package.getPath(), this.taskParams);
if(this.taskParams.UseWebDeploy && this.taskParams.DeploymentType === DeploymentType.zipDeploy) {
var _isMSBuildPackage = await this.taskParams.Package.isMSBuildPackage();
if(_isMSBuildPackage) {
throw Error(tl.loc("Publishusingzipdeploynotsupportedformsbuildpackage"));
}
else if(this.taskParams.VirtualApplication) {
throw Error(tl.loc("Publishusingzipdeploynotsupportedforvirtualapplication"));
}
else if(this.taskParams.Package.getPackageType() === PackageType.war) {
throw Error(tl.loc("Publishusingzipdeploydoesnotsupportwarfile"));
}
}
if(tl.stats(webPackage).isDirectory()) {
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath);
tl.debug("Compressed folder into zip " + webPackage);
}
tl.debug("Initiated deployment via kudu service for webapp package : ");
var updateApplicationSetting = ParameterParser.parse(removeRunFromZipAppSetting)
var deleteApplicationSetting = ParameterParser.parse(deleteOldRunFromZipAppSetting)
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(updateApplicationSetting, deleteApplicationSetting);
if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
}
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
await this.PostDeploymentStep();
}
示例6: DeployUsingKuduDeploy
/**
* Deploys website using Kudu REST API
*
* @param webDeployPkg Web deploy package
* @param webAppName Web App Name
* @param publishingProfile Azure RM Connection Details
* @param virtualApplication Virtual Application Name
* @param isFolderBasedDeployment Input is folder or not
*
*/
async function DeployUsingKuduDeploy(webDeployPkg, azureWebAppDetails, publishingProfile, virtualApplication, isFolderBasedDeployment, takeAppOfflineFlag) {
var tempPackagePath = null;
try {
var virtualApplicationMappings = azureWebAppDetails.properties.virtualApplications;
var webAppZipFile = webDeployPkg;
if(isFolderBasedDeployment) {
tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('System.DefaultWorkingDirectory'), false);
webAppZipFile = await zipUtility.archiveFolder(webDeployPkg, "", tempPackagePath);
tl.debug("Compressed folder " + webDeployPkg + " into zip : " + webAppZipFile);
} else {
if (await deployUtility.isMSDeployPackage(webAppZipFile)) {
throw new Error(tl.loc("MSDeploygeneratedpackageareonlysupportedforWindowsplatform"));
}
}
var physicalPath = "/site/wwwroot";
var virtualPath = "/";
if(virtualApplication) {
var pathMappings = kuduUtility.getVirtualAndPhysicalPaths(virtualApplication, virtualApplicationMappings);
if(pathMappings[1] != null) {
virtualPath = pathMappings[0];
physicalPath = pathMappings[1];
} else {
throw Error(tl.loc("VirtualApplicationDoesNotExist", virtualApplication));
}
}
await kuduUtility.deployWebAppPackage(webAppZipFile, publishingProfile, virtualPath, physicalPath, takeAppOfflineFlag);
console.log(tl.loc('PackageDeploymentSuccess'));
}
catch(error) {
tl.error(tl.loc('PackageDeploymentFailed'));
throw Error(error);
}
finally {
if(tempPackagePath) {
tl.rmRF(tempPackagePath, true);
}
}
}
示例7: DeployWebAppStep
public async DeployWebAppStep() {
var webPackage = await FileTransformsUtility.applyTransformations(this.taskParams.Package.getPath(), this.taskParams);
if(this.taskParams.UseWebDeploy && this.taskParams.DeploymentType === DeploymentType.runFromZip) {
var _isMSBuildPackage = await this.taskParams.Package.isMSBuildPackage();
if(_isMSBuildPackage) {
throw Error(tl.loc("Publishusingzipdeploynotsupportedformsbuildpackage"));
}
else if(this.taskParams.VirtualApplication) {
throw Error(tl.loc("Publishusingzipdeploynotsupportedforvirtualapplication"));
}
else if(this.taskParams.Package.getPackageType() === PackageType.war) {
throw Error(tl.loc("Publishusingzipdeploydoesnotsupportwarfile"));
}
}
if(tl.stats(webPackage).isDirectory()) {
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath);
tl.debug("Compressed folder into zip " + webPackage);
}
tl.debug("Initiated deployment via kudu service for webapp package : ");
var addCustomApplicationSetting = ParameterParser.parse(runFromZipAppSetting);
var deleteCustomApplicationSetting = ParameterParser.parse(oldRunFromZipAppSetting);
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(addCustomApplicationSetting, deleteCustomApplicationSetting);
if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
}
await this.kuduServiceUtility.deployUsingRunFromZip(webPackage,
{ slotName: this.appService.getSlot() });
await this.PostDeploymentStep();
}
示例8: main
async function main() {
tl.setResourcePath(path.join( __dirname, 'task.json'));
let webPackage = new Package(tl.getPathInput('folderPath', true));
let packagePath = webPackage.getPath();
let fileType = tl.getInput("fileType", false);
let targetFiles = tl.getDelimitedInput('targetFiles', '\n', false);
let xmlTransformation = tl.getBoolInput('enableXmlTransform', false);
let xmlTransformationRules = tl.getDelimitedInput('xmlTransformationRules', '\n', false);
let applyFileTransformFlag = fileType || xmlTransformation;
if (applyFileTransformFlag) {
let isFolderBasedDeployment: boolean = tl.stats(packagePath).isDirectory();
if(!isFolderBasedDeployment) {
var folderPath = await deployUtility.generateTemporaryFolderForDeployment(isFolderBasedDeployment, packagePath, webPackage.getPackageType());
fileTransformationsUtility.advancedFileTransformations(isFolderBasedDeployment, targetFiles, xmlTransformation, fileType, folderPath, xmlTransformationRules);
await zipUtility.archiveFolder(folderPath, path.dirname(packagePath), path.basename(packagePath));
}
else {
fileTransformationsUtility.advancedFileTransformations(isFolderBasedDeployment, targetFiles, xmlTransformation, fileType, packagePath, xmlTransformationRules);
}
}
else {
tl.debug('File Tranformation not enabled');
}
}
示例9: DeployWebAppStep
public async DeployWebAppStep() {
tl.debug('Performing Linux built-in package deployment');
var isNewValueUpdated: boolean = false;
if(this.taskParams.isFunctionApp) {
var linuxFunctionRuntimeSetting = "";
if(this.taskParams.RuntimeStack){
linuxFunctionRuntimeSetting = linuxFunctionRuntimeSettingName + linuxFunctionRuntimeSettingValue.get(this.taskParams.RuntimeStack);
}
var linuxFunctionAppSetting = linuxFunctionRuntimeSetting + linuxFunctionStorageSetting;
var customApplicationSetting = ParameterParser.parse(linuxFunctionAppSetting);
isNewValueUpdated = await this.appServiceUtility.updateAndMonitorAppSettings(customApplicationSetting);
}
if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
}
switch(this.taskParams.Package.getPackageType()){
case PackageType.folder:
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
let archivedWebPackage = await zipUtility.archiveFolder(this.taskParams.Package.getPath(), "", tempPackagePath);
tl.debug("Compressed folder into zip " + archivedWebPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(archivedWebPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
break;
case PackageType.zip:
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(this.taskParams.Package.getPath(), this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
break;
case PackageType.jar:
tl.debug("Initiated deployment via kudu service for webapp jar package : "+ this.taskParams.Package.getPath());
var folderPath = await webCommonUtility.generateTemporaryFolderForDeployment(false, this.taskParams.Package.getPath(), PackageType.jar);
var jarName = webCommonUtility.getFileNameFromPath(this.taskParams.Package.getPath(), ".jar");
var destRootPath = "/home/site/wwwroot/";
var script = 'java -jar "' + destRootPath + jarName + '.jar' + '" --server.port=80';
var initScriptFileName = "startupscript_" + jarName + ".sh";
var initScriptFile = path.join(folderPath, initScriptFileName);
var destInitScriptPath = destRootPath + initScriptFileName;
if(!this.taskParams.AppSettings) {
this.taskParams.AppSettings = "-INIT_SCRIPT " + destInitScriptPath;
}
if(this.taskParams.AppSettings.indexOf("-INIT_SCRIPT") < 0) {
this.taskParams.AppSettings += " -INIT_SCRIPT " + destInitScriptPath;
}
this.taskParams.AppSettings = this.taskParams.AppSettings.trim();
tl.writeFile(initScriptFile, script, { encoding: 'utf8' });
var output = await webCommonUtility.archiveFolderForDeployment(false, folderPath);
var webPackage = output.webDeployPkg;
tl.debug("Initiated deployment via kudu service for webapp jar package : "+ webPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
break;
case PackageType.war:
tl.debug("Initiated deployment via kudu service for webapp war package : "+ this.taskParams.Package.getPath());
var warName = webCommonUtility.getFileNameFromPath(this.taskParams.Package.getPath(), ".war");
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingWarDeploy(this.taskParams.Package.getPath(),
{ slotName: this.appService.getSlot() }, warName);
break;
default:
throw new Error(tl.loc('Invalidwebapppackageorfolderpathprovided', this.taskParams.Package.getPath()));
}
await this.appServiceUtility.updateStartupCommandAndRuntimeStack(this.taskParams.RuntimeStack, this.taskParams.StartupCommand);
await this.PostDeploymentStep();
}