ng-deploy-azure icon indicating copy to clipboard operation
ng-deploy-azure copied to clipboard

Allow multiple deploys from same project

Open jakobgn opened this issue 5 years ago • 3 comments

Description

The hosting property in azure.json is already designed as an enumerable data structure, however only a single configuration can currently be deployed at a time. I.e if I have multiple configs defined in azure.json, only the first has any impact.

Value: Deploy same project with various build-configurations

Solution: Change getAzureHostingConfig to return an array of hosting configs rather than finding the first match. Then run deploy on each configuration.

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)

jakobgn avatar Oct 28 '19 14:10 jakobgn

Simple solution (works in my machine™):

const azureProjects = getAzureHostingConfig(workspaceRoot, context.target.project, builderConfig.config); if (!azureProjects || azureProjects.length === 0) { throw new Error(Configuration for project ${context.target.project} was not found in azure.json.); } return (await Promise.all( azureProjects.map(async azureProject => { try { await deploy(context, join(workspaceRoot, project.root), azureProject); return { success: true }; } catch (e) { context.logger.error('Error when trying to deploy: ' + azureProject.azureHosting.account); context.logger.error(e.message); return { success: false }; } }) )).every(x => x.success) ? { success: true } : { success: false }; } );

export function getAzureHostingConfig( projectRoot: string, target: string, azureConfigFile: string ): AzureHostingConfig[] | undefined { const azureJson: AzureJSON = JSON.parse(readFileSync(join(projectRoot, azureConfigFile), 'UTF-8')); if (!azureJson) { throw new Error(Cannot read configuration file "${azureConfigFile}"); } const projects = azureJson.hosting; return projects.filter(project => project.app.project === target); }

jakobgn avatar Oct 28 '19 14:10 jakobgn

Probably ng add needs to be updated as well, to not overwrite when new configurations are added.

Authentication should be run before deploy as well, to avoid multiple signin links

jakobgn avatar Oct 28 '19 14:10 jakobgn

Thanks for reporting this issue. Would you be interested in creating a PR?

manekinekko avatar Feb 09 '20 01:02 manekinekko