diff --git a/.yarn/plugins/@sirensolutions/yarn-plugin-gar-auth.cjs b/.yarn/plugins/@sirensolutions/yarn-plugin-gar-auth.cjs new file mode 100644 index 00000000000..64033acc4cd --- /dev/null +++ b/.yarn/plugins/@sirensolutions/yarn-plugin-gar-auth.cjs @@ -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()}` + } + } + }; + } +}; diff --git a/.yarnrc.yml b/.yarnrc.yml index c64bd84f323..4b9b170bc94 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -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" diff --git a/README.md b/README.md index 6295b7327a4..071efb0cc3d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ To set up the repo, run the following commands: ```shell -npm run auth yarn yarn bootstrap ``` @@ -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 ``` diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 38ea4991415..3fb7124b0f5 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -34,7 +34,6 @@ pipeline { sh(""" set +x gcloud auth activate-service-account --key-file="${GCLOUD_KEY_FILE}" - npm run auth yarn """ ) diff --git a/package.json b/package.json index a9cf2b3ef85..2f589bd34fc 100644 --- a/package.json +++ b/package.json @@ -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",