From 95b362139bfa5c7270d25c9bbe375231f5af33eb Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 14:51:56 -0700 Subject: [PATCH 1/8] rename npm references to yarn and consolidate debug workspace steps --- build/yaml/templates/component-template.yml | 10 ++++++---- build/yaml/templates/npm-package-steps.yml | 4 +--- build/yaml/templates/npm-versioning-steps.yml | 2 -- .../{npm-build-steps.yml => yarn-build-steps.yml} | 2 -- .../{npm-test-steps.yml => yarn-test-steps.yml} | 0 5 files changed, 7 insertions(+), 11 deletions(-) rename build/yaml/templates/{npm-build-steps.yml => yarn-build-steps.yml} (89%) rename build/yaml/templates/{npm-test-steps.yml => yarn-test-steps.yml} (100%) diff --git a/build/yaml/templates/component-template.yml b/build/yaml/templates/component-template.yml index bd27ea611e..cd539a6ff8 100644 --- a/build/yaml/templates/component-template.yml +++ b/build/yaml/templates/component-template.yml @@ -8,8 +8,9 @@ stages: - job: job_build_npm displayName: Build Node project steps: - - template: npm-build-steps.yml - - template: npm-test-steps.yml + - template: yarn-build-steps.yml + - template: yarn-test-steps.yml + - template: debug-workspace-steps.yml - stage: stage_package_node displayName: 'Node: Build, Version & Pack' @@ -18,10 +19,11 @@ stages: - job: pack_npm displayName: 'Build & Pack Node project' steps: - - template: npm-build-steps.yml - - template: npm-test-steps.yml + - template: yarn-build-steps.yml + - template: yarn-test-steps.yml - template: npm-versioning-steps.yml - template: npm-package-steps.yml + - template: debug-workspace-steps.yml - stage: stage_build_nuget displayName: '.NET: Build & Test' diff --git a/build/yaml/templates/npm-package-steps.yml b/build/yaml/templates/npm-package-steps.yml index 4a0b9a71b8..a5bd5b082f 100644 --- a/build/yaml/templates/npm-package-steps.yml +++ b/build/yaml/templates/npm-package-steps.yml @@ -33,10 +33,8 @@ steps: TargetFolder: '$(Build.ArtifactStagingDirectory)\npm' - task: PublishBuildArtifacts@1 - displayName: 'Publish the npm package' + displayName: 'Publish the npm package to artifacts' inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)\npm' ArtifactName: 'npm' publishLocation: 'Container' - -- template: debug-workspace-steps.yml diff --git a/build/yaml/templates/npm-versioning-steps.yml b/build/yaml/templates/npm-versioning-steps.yml index 9cb7e95fb1..a028d41658 100644 --- a/build/yaml/templates/npm-versioning-steps.yml +++ b/build/yaml/templates/npm-versioning-steps.yml @@ -61,5 +61,3 @@ steps: tags: | NpmPackageVersion: $(NpmPackageVersion) continueOnError: true - -- template: debug-workspace-steps.yml \ No newline at end of file diff --git a/build/yaml/templates/npm-build-steps.yml b/build/yaml/templates/yarn-build-steps.yml similarity index 89% rename from build/yaml/templates/npm-build-steps.yml rename to build/yaml/templates/yarn-build-steps.yml index b899f99240..881ec130c5 100644 --- a/build/yaml/templates/npm-build-steps.yml +++ b/build/yaml/templates/yarn-build-steps.yml @@ -13,5 +13,3 @@ steps: yarn exec npm run --if-present build displayName: 'Run build if it exists' workingDirectory: '$(WorkingDirectory)' - -- template: debug-workspace-steps.yml diff --git a/build/yaml/templates/npm-test-steps.yml b/build/yaml/templates/yarn-test-steps.yml similarity index 100% rename from build/yaml/templates/npm-test-steps.yml rename to build/yaml/templates/yarn-test-steps.yml From baf25aa29ad9ce9fca867afd1cc4e65715bddcda Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 14:54:56 -0700 Subject: [PATCH 2/8] Rename addl npm to yarn refs --- build/yaml/templates/component-template.yml | 2 +- build/yaml/templates/yarn-build-steps.yml | 2 +- .../{npm-package-steps.yml => yarn-package-steps.yml} | 4 ++-- build/yaml/templates/yarn-test-steps.yml | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) rename build/yaml/templates/{npm-package-steps.yml => yarn-package-steps.yml} (93%) diff --git a/build/yaml/templates/component-template.yml b/build/yaml/templates/component-template.yml index cd539a6ff8..3c9f0c7592 100644 --- a/build/yaml/templates/component-template.yml +++ b/build/yaml/templates/component-template.yml @@ -22,7 +22,7 @@ stages: - template: yarn-build-steps.yml - template: yarn-test-steps.yml - template: npm-versioning-steps.yml - - template: npm-package-steps.yml + - template: yarn-package-steps.yml - template: debug-workspace-steps.yml - stage: stage_build_nuget diff --git a/build/yaml/templates/yarn-build-steps.yml b/build/yaml/templates/yarn-build-steps.yml index 881ec130c5..6aa80571f1 100644 --- a/build/yaml/templates/yarn-build-steps.yml +++ b/build/yaml/templates/yarn-build-steps.yml @@ -11,5 +11,5 @@ steps: - script: | yarn exec npm run --if-present build - displayName: 'Run build if it exists' + displayName: 'Run `yarn build` if it exists' workingDirectory: '$(WorkingDirectory)' diff --git a/build/yaml/templates/npm-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml similarity index 93% rename from build/yaml/templates/npm-package-steps.yml rename to build/yaml/templates/yarn-package-steps.yml index a5bd5b082f..1631c60e81 100644 --- a/build/yaml/templates/npm-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -22,11 +22,11 @@ steps: - script: | yarn pack - displayName: 'Generate package' + displayName: 'Run `yarn pack`' workingDirectory: '$(WorkingDirectory)' - task: CopyFiles@2 - displayName: 'Copy packages' + displayName: 'Copy packages to staging directory' inputs: SourceFolder: '$(WorkingDirectory)' Contents: '*.tgz' diff --git a/build/yaml/templates/yarn-test-steps.yml b/build/yaml/templates/yarn-test-steps.yml index 06c8a40a15..477fcbcca6 100644 --- a/build/yaml/templates/yarn-test-steps.yml +++ b/build/yaml/templates/yarn-test-steps.yml @@ -9,18 +9,18 @@ steps: if (Test-Path -Path package.json) { $package = Get-Content package.json | ConvertFrom-Json $result = $package.scripts -and $package.scripts.test - Write-Host "##vso[task.setvariable variable=NpmRunTest;]$result" + Write-Host "##vso[task.setvariable variable=YarnRunTest;]$result" } else { Write-Host "Missing package.json" exit 1 } displayName: 'Determine if test script is present' - name: SetNpmRunTest + name: SetYarnRunTest workingDirectory: '$(WorkingDirectory)' - script: | yarn run test - condition: eq(variables.NpmRunTest, true) + condition: eq(variables.YarnRunTest, true) continueOnError: true - displayName: 'Run test if it exists' + displayName: 'Run `yarn test` if it exists' workingDirectory: '$(WorkingDirectory)' From 96335c532a0b12808308391aba6e0946c2a6e251 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 15:07:58 -0700 Subject: [PATCH 3/8] Add $(NpmPackageVersion) to yarn pack filename --- build/yaml/templates/yarn-package-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index 1631c60e81..22cea937c5 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -21,7 +21,7 @@ steps: workingDirectory: '$(WorkingDirectory)' - script: | - yarn pack + yarn pack --filename $(NpmPackageVersion) displayName: 'Run `yarn pack`' workingDirectory: '$(WorkingDirectory)' From 2113c804a1788090c78e77014f1429741b7e27da Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 15:21:30 -0700 Subject: [PATCH 4/8] add tgz suffix to yarn pack step --- build/yaml/templates/yarn-package-steps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index 22cea937c5..4aac9b01b3 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -1,7 +1,7 @@ steps: - powershell: | if (Test-Path -Path package.json) { - # Get package.json ojbect + # Get package.json object $packageJson = Get-Content package.json; $packageJsonData = $packageJson | ConvertFrom-Json; @@ -21,7 +21,7 @@ steps: workingDirectory: '$(WorkingDirectory)' - script: | - yarn pack --filename $(NpmPackageVersion) + yarn pack --filename '$(NpmPackageVersion)'.tgz displayName: 'Run `yarn pack`' workingDirectory: '$(WorkingDirectory)' From ec741ab7beefbac33bff4c1ef4b4dd4edfb92212 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 15:32:58 -0700 Subject: [PATCH 5/8] get name for yarn pack --- build/yaml/templates/yarn-package-steps.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index 4aac9b01b3..5d2d327402 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -5,6 +5,10 @@ steps: $packageJson = Get-Content package.json; $packageJsonData = $packageJson | ConvertFrom-Json; + # Get name and save as pipeline variable + $name = $packageJsonData.name + Write-Host "##vso[task.setvariable variable=NpmPackageName;]$name" + # Get variable passed from Setup stage $packageVersion = "$(NpmPackageVersion)"; @@ -21,7 +25,7 @@ steps: workingDirectory: '$(WorkingDirectory)' - script: | - yarn pack --filename '$(NpmPackageVersion)'.tgz + yarn pack --filename $(NpmPackageName)-$(NpmPackageVersion).tgz displayName: 'Run `yarn pack`' workingDirectory: '$(WorkingDirectory)' From 9cb1c6d71e67a15a81742ee39b6b44c4f4164f64 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 16:01:05 -0700 Subject: [PATCH 6/8] remove invalid filename characters --- build/yaml/templates/yarn-package-steps.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index 5d2d327402..91bff5a493 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -5,8 +5,9 @@ steps: $packageJson = Get-Content package.json; $packageJsonData = $packageJson | ConvertFrom-Json; - # Get name and save as pipeline variable - $name = $packageJsonData.name + # Get name, strip invalid filename characters up to '/' and save as pipeline variable + $name = $packageJsonData.name -replace ".*\/" + Write-Host $packagejsonData Write-Host "##vso[task.setvariable variable=NpmPackageName;]$name" # Get variable passed from Setup stage From c2659b9cbd96d0486d722b77e86323627ea165eb Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 16:32:44 -0700 Subject: [PATCH 7/8] Write package name and file name to output --- build/yaml/templates/component-template.yml | 4 ++-- build/yaml/templates/yarn-package-steps.yml | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build/yaml/templates/component-template.yml b/build/yaml/templates/component-template.yml index 3c9f0c7592..cce084d0c1 100644 --- a/build/yaml/templates/component-template.yml +++ b/build/yaml/templates/component-template.yml @@ -6,14 +6,14 @@ stages: condition: and(or(eq(variables.ComponentType, 'declarativeAsset'), eq(variables.ComponentType, 'generator'), and(eq(variables.ComponentType, 'codeExtension'), eq(variables.Language, 'js'))), not(eq(variables.PublishPackageArtifacts, true))) jobs: - job: job_build_npm - displayName: Build Node project + displayName: Build & Test Node project steps: - template: yarn-build-steps.yml - template: yarn-test-steps.yml - template: debug-workspace-steps.yml - stage: stage_package_node - displayName: 'Node: Build, Version & Pack' + displayName: 'Node: Build, Test, Version & Pack' condition: and(or(eq(variables.ComponentType, 'declarativeAsset'), eq(variables.ComponentType, 'generator'), and(eq(variables.ComponentType, 'codeExtension'), eq(variables.Language, 'js'))), eq(variables.PublishPackageArtifacts, true)) jobs: - job: pack_npm diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index 91bff5a493..e8356b1624 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -6,9 +6,10 @@ steps: $packageJsonData = $packageJson | ConvertFrom-Json; # Get name, strip invalid filename characters up to '/' and save as pipeline variable - $name = $packageJsonData.name -replace ".*\/" - Write-Host $packagejsonData - Write-Host "##vso[task.setvariable variable=NpmPackageName;]$name" + $packageName = $packageJsonData.name -replace ".*\/" + "Package name = $packageJsonData.name"; + "Package file name = $packageName"; + Write-Host "##vso[task.setvariable variable=NpmPackageFileName;]$packageName" # Get variable passed from Setup stage $packageVersion = "$(NpmPackageVersion)"; @@ -26,7 +27,7 @@ steps: workingDirectory: '$(WorkingDirectory)' - script: | - yarn pack --filename $(NpmPackageName)-$(NpmPackageVersion).tgz + yarn pack --filename $(NpmPackageFileName)-$(NpmPackageVersion).tgz displayName: 'Run `yarn pack`' workingDirectory: '$(WorkingDirectory)' From 404e71967c02389d9380307994d2b12f4784aa66 Mon Sep 17 00:00:00 2001 From: Ryan Lengel Isgrig Date: Thu, 8 Jul 2021 16:47:35 -0700 Subject: [PATCH 8/8] clean up comments --- build/yaml/templates/yarn-package-steps.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/yaml/templates/yarn-package-steps.yml b/build/yaml/templates/yarn-package-steps.yml index e8356b1624..4befed4fc2 100644 --- a/build/yaml/templates/yarn-package-steps.yml +++ b/build/yaml/templates/yarn-package-steps.yml @@ -6,9 +6,12 @@ steps: $packageJsonData = $packageJson | ConvertFrom-Json; # Get name, strip invalid filename characters up to '/' and save as pipeline variable - $packageName = $packageJsonData.name -replace ".*\/" - "Package name = $packageJsonData.name"; + $packageName = $packageJsonData.name + "Package name = $packageName"; + + $packageName = $packageName -replace ".*\/" "Package file name = $packageName"; + Write-Host "##vso[task.setvariable variable=NpmPackageFileName;]$packageName" # Get variable passed from Setup stage