diff --git a/.github/scripts/codeartifact-login.sh b/.github/scripts/codeartifact-login.sh new file mode 100755 index 0000000000..177f1d5824 --- /dev/null +++ b/.github/scripts/codeartifact-login.sh @@ -0,0 +1,15 @@ +AWS_VERSION=$(aws --version 2>&1 | cut -d/ -f2 | cut -d. -f1) +echo "aws-cli/$AWS_VERSION" + +if [ "$AWS_VERSION" -lt 2 ]; then + echo "Skipping .npmrc generation because AWS CLI version is less than 2" +else + echo "Generating .npmrc" + REPO_ENDPOINT=$(aws codeartifact get-repository-endpoint --domain roo --repository roo-dev --format npm | jq -r '.repositoryEndpoint') + echo "registry=$REPO_ENDPOINT" > .npmrc + + CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain roo --query authorizationToken --output text) + + REPO_PATH=$(echo $REPO_ENDPOINT | sed 's/https://g') + echo "$REPO_PATH:_authToken=$CODEARTIFACT_AUTH_TOKEN" >> .npmrc +fi diff --git a/.gitignore b/.gitignore index cf34c53d64..19f0b5a72c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,7 @@ node_modules .DS_Store +.npmrc + # Builds bin \ No newline at end of file diff --git a/package.json b/package.json index 81e0c1fb1f..f147682083 100644 --- a/package.json +++ b/package.json @@ -130,11 +130,13 @@ "scripts": { "build": "npm run build:webview && npm run vsix", "build:webview": "cd webview-ui && npm run build", + "co:login": "scripts/codeartifact-login.sh", + "co:install": "npm run co:login && npm install", "changeset": "changeset", "check-types": "tsc --noEmit", "compile": "npm run check-types && npm run lint && node esbuild.js", "compile-tests": "tsc -p . --outDir out", - "install:all": "npm install && cd webview-ui && npm install", + "install:all": "npm run co:install && cd webview-ui && npm install", "lint": "eslint src --ext ts", "package": "npm run build:webview && npm run check-types && npm run lint && node esbuild.js --production", "pretest": "npm run compile-tests && npm run compile && npm run lint",