Skip to content

Commit

Permalink
Add Yarn plugin for GAR authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
daradermody committed Nov 20, 2024
1 parent 39e388a commit 29eaaad
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .yarn/plugins/@sirensolutions/yarn-plugin-gar-auth.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
name: `gar-auth`,
factory: require => {
const util = require('util');
const exec = util.promisify(require('child_process').exec);
let cachedToken

async function getToken() {
if (!cachedToken) {
const {stdout} = await exec('gcloud auth print-access-token');
cachedToken = stdout.trim();
}
return cachedToken;
}

return {
default: {
hooks: {
validateProject: getToken,
getNpmAuthenticationHeader: async () => `Bearer ${await getToken()}`
}
}
};
}
};
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ npmPublishRegistry: "https://europe-west1-npm.pkg.dev/siren-cicd/npm-standard/"
npmScopes:
antv:
npmRegistryServer: "https://europe-west1-npm.pkg.dev/siren-cicd/npm-virtual/"

plugins:
- checksum: 7a993ef2944928530db74ca2f844dc21324bdc768bb0744b772277b114f28da4625903f4109fc90f3de6621e97c646f8969167df3435ee7e443d79b8a4806a62
path: .yarn/plugins/@sirensolutions/yarn-plugin-gar-auth.cjs
spec: "@sirensolutions/yarn-plugin-gar-auth.cjs"
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
To set up the repo, run the following commands:

```shell
npm run auth
yarn
yarn bootstrap
```
Expand All @@ -22,7 +21,6 @@ To publish, run the following commands for the package you want to publish (`cor

```shell
npm run build:all
yarn auth
cd packages/core # Or: element, plugin, pc, g6
yarn npm publish
```
Expand Down
1 change: 0 additions & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pipeline {
sh("""
set +x
gcloud auth activate-service-account --key-file="${GCLOUD_KEY_FILE}"
npm run auth
yarn
"""
)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"packages/*"
],
"scripts": {
"auth": "yarn config set --home 'npmRegistries[\"https://europe-west1-npm.pkg.dev/siren-cicd/npm-virtual/\"].npmAuthToken' $(gcloud auth print-access-token) && yarn config set --home 'npmRegistries[\"https://europe-west1-npm.pkg.dev/siren-cicd/npm-standard/\"].npmAuthToken' $(gcloud auth print-access-token)",
"build:demos": "cd ./packages/pc && npm run demos",
"build:site": "cd ./packages/site && npm run site:build",
"build:core": "cd ./packages/core && npm run build",
Expand Down

0 comments on commit 29eaaad

Please sign in to comment.