# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- main

pool:
  vmImage: ubuntu-latest

stages:
- stage: Build
  jobs:
  - job: ngBuild
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: 'v18.10'
      displayName: 'Install Node.js'

    - script: |
        npm install -g @angular/cli
      displayName: 'install angular cli'

    - script: |
        npm install
      displayName: 'npm install'
    
    - script: |
        npm rebuild node-sass
      displayName: 'npm rebuild node-sass'  

    - script: |
        npm run build:staging
      displayName: 'ng build'  

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: 'dist/pos'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true  
      displayName: Archive Files
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'
      displayName: Publish Artifacts
