@@ -43,41 +43,46 @@ stages:
4343 inputs :
4444 targetType : ' inline'
4545 script : |
46- # Define the root path where projects are located
47- rootPath="$(Build.SourcesDirectory)/projects"
48-
49- # Get all first-level subdirectories in the specified root path
50- subdirectories=$(find "$rootPath" -mindepth 1 -maxdepth 1 -type d)
51-
52- for subdirectory in $subdirectories; do
53- # Extract the directory name from the path
54- dirName=$(basename "$subdirectory")
55-
56- # Give each sample a version in its package.json file - for traceability
57- cd "$subdirectory"
58- echo "Calling npm version command"
59- npm version $(Build.BuildNumber) --no-git-tag-version
60-
61- # Check if the directory name is already camel-case
62- if [[ "$dirName" =~ ^[A-Z]+[a-z]+([A-Z][a-z]*)*$ ]]; then
63- # If already camel-case, print it as is
64- echo "$dirName"
65- else
66- # Convert to camel-case (capitalize first letters and remove hyphens)
67- dirName=$(echo "$dirName" | sed -E 's/(^|-)([a-z])/\U\2/g')
68-
69- fi
70-
71- echo "Processing directory: $dirName"
72-
73- # Define the name for the zip file
74- zipName="$(Build.ArtifactStagingDirectory)/IgniteUI_Angular_ApplicationSample_${dirName}_Source.zip"
75- echo "Creating ZIP: $zipName"
76-
77- # Compress the directory into a ZIP file
78- (cd "$subdirectory" && zip -r "$zipName" .)
79- done
80-
46+ create_zips() {
47+ local rootPath="$1"
48+ if [ -d "$rootPath" ]; then
49+ # Get all first-level subdirectories in the specified root path
50+ subdirectories=$(find "$rootPath" -mindepth 1 -maxdepth 1 -type d)
51+ for subdirectory in $subdirectories; do
52+ # Extract the directory name from the path
53+ dirName=$(basename "$subdirectory")
54+
55+ # Give each sample a version in its package.json file - for traceability
56+ cd "$subdirectory"
57+ echo "Setting project version in package.json to $(Build.BuildNumber) for $dirName"
58+ npm version $(Build.BuildNumber) --no-git-tag-version
59+
60+ # Check if the directory name is already camel-case
61+ if [[ "$dirName" =~ ^[A-Z]+[a-z]+([A-Z][a-z]*)*$ ]]; then
62+ # If already camel-case, print it as is
63+ echo "$dirName"
64+ else
65+ # Convert to camel-case (capitalize first letters and remove hyphens)
66+ dirName=$(echo "$dirName" | sed -E 's/(^|-)([a-z])/\U\2/g')
67+ fi
68+
69+ echo "Processing directory: $dirName"
70+ # Define the name for the zip file
71+ zipName="$(Build.ArtifactStagingDirectory)/IgniteUI_Angular_ApplicationSample_${dirName}_Source.zip"
72+ echo "Creating ZIP: $zipName"
73+
74+ # Compress the directory into a ZIP file
75+ (cd "$subdirectory" && zip -r "$zipName" .)
76+ done
77+ fi
78+ }
79+
80+ # Pass 1: All first-level directories in projects/
81+ create_zips "$(Build.SourcesDirectory)/projects"
82+
83+ # Pass 2: All first-level directories in projects/charts/
84+ create_zips "$(Build.SourcesDirectory)/projects/charts"
85+
8186 echo "All sample projects have been compressed and saved to the artifacts directory."
8287
8388 - task : PublishPipelineArtifact@1
0 commit comments