From 9577e9e928b0ec337ea7104b7cb8b02a05ee23fa Mon Sep 17 00:00:00 2001 From: Corey Pyle Date: Thu, 22 Feb 2024 17:03:44 -0500 Subject: [PATCH] JavaScript (v3): Add package validation script. --- .github/workflows/javascript.yml | 3 +++ .../bedrock-agent-runtime/package.json | 2 +- javascriptv3/github_scripts/validate_packages.sh | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 javascriptv3/github_scripts/validate_packages.sh diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index 8fcfcd353c0..efcde19c317 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -34,3 +34,6 @@ jobs: changed_files=(${{steps.changed-files.outputs.all_changed_files}}) npm run --prefix javascriptv3 ci-lint -- ${changed_files[@]//javascriptv3\/} name: Lint added and modified files + - run: ./javascriptv3/github_scripts/validate_packages.sh + name: Validate package names + diff --git a/javascriptv3/example_code/bedrock-agent-runtime/package.json b/javascriptv3/example_code/bedrock-agent-runtime/package.json index 71c7bb81ffa..bafe95a2bc3 100644 --- a/javascriptv3/example_code/bedrock-agent-runtime/package.json +++ b/javascriptv3/example_code/bedrock-agent-runtime/package.json @@ -1,5 +1,5 @@ { - "name": "bedrock-agent-runtime-examples", + "name": "@aws-doc-sdk-examples/bedrock-agent-runtime-examples", "version": "1.0.0", "author": "Dinuda Yaggahavita ", "license": "Apache-2.0", diff --git a/javascriptv3/github_scripts/validate_packages.sh b/javascriptv3/github_scripts/validate_packages.sh new file mode 100755 index 00000000000..65dfc27aac8 --- /dev/null +++ b/javascriptv3/github_scripts/validate_packages.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e +errors_found=false +packages=$(npm query --prefix javascriptv3 .workspace | jq -r '.[].name') +for package_name in $packages; do + if [[ "$package_name" != *"@aws-doc-sdk-examples/"* ]]; then + echo "Error: Prefix '@aws-doc-sdk-examples/' is missing in package '$package_name'" + errors_found=true + fi +done + +if [ "$errors_found" = true ]; then + exit 1 +fi