From 3ff5791de097413d80ec74cc3f7ccef1289abd6b Mon Sep 17 00:00:00 2001 From: Rowan Manning <138944+rowanmanning@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:00:49 +0000 Subject: [PATCH 1/9] feat: add Cloudsmith auth This adds in the orb to authenticate with Cloudsmith via OIDC. Our Cloudsmith orb requires two environment variables to work: * CLOUDSMITH_ORGANISATION * CLOUDSMITH_SERVICE_ACCOUNT To allow us to specify these in Tool Kit config instead (which is a lot cleaner, the config lives in the code etc) we need to define a schema for a nonexistent `cloudsmith` plugin and then pass params through into the CircleCI config. Co-Authored-By: Alex Muller Co-Authored-By: Ivo Murrell --- lib/schemas/src/plugins.ts | 2 ++ lib/schemas/src/plugins/cloudsmith.ts | 6 ++++++ orb/src/@orb.yml | 1 + orb/src/jobs/deploy-production.yml | 17 +++++++++++++++++ orb/src/jobs/deploy-review.yml | 17 +++++++++++++++++ orb/src/jobs/deploy-staging.yml | 17 +++++++++++++++++ plugins/circleci-deploy/.toolkitrc.yml | 16 ++++++++++++++++ 7 files changed, 76 insertions(+) create mode 100644 lib/schemas/src/plugins/cloudsmith.ts diff --git a/lib/schemas/src/plugins.ts b/lib/schemas/src/plugins.ts index d473dee1e..1f809216c 100644 --- a/lib/schemas/src/plugins.ts +++ b/lib/schemas/src/plugins.ts @@ -1,6 +1,7 @@ import { z } from 'zod' import { CircleCISchema } from './plugins/circleci' +import { CloudsmithSchema } from './plugins/cloudsmith' import { DopplerSchema } from './plugins/doppler' import { RootSchema } from './plugins/dotcom-tool-kit' import { HerokuSchema } from './plugins/heroku' @@ -28,6 +29,7 @@ export const legacyPluginOptions: Record = { export const PluginSchemas = { 'app root': RootSchema, '@dotcom-tool-kit/circleci': CircleCISchema, + '@dotcom-tool-kit/cloudsmith': CloudsmithSchema, '@dotcom-tool-kit/doppler': DopplerSchema, '@dotcom-tool-kit/heroku': HerokuSchema, '@dotcom-tool-kit/lint-staged-npm': LintStagedNpmSchema, diff --git a/lib/schemas/src/plugins/cloudsmith.ts b/lib/schemas/src/plugins/cloudsmith.ts new file mode 100644 index 000000000..10510db80 --- /dev/null +++ b/lib/schemas/src/plugins/cloudsmith.ts @@ -0,0 +1,6 @@ +import { z } from 'zod' + +export const CloudsmithSchema = z.object({ + organisation: z.string().optional().describe('the Cloudsmith organisation'), + serviceAccount: z.string().optional().describe('the Cloudsmith service account') +}) diff --git a/orb/src/@orb.yml b/orb/src/@orb.yml index 0199f6703..cd39cbadb 100644 --- a/orb/src/@orb.yml +++ b/orb/src/@orb.yml @@ -13,5 +13,6 @@ display: orbs: node: circleci/node@5.0.2 change-api: financial-times/change-api@1.0.9 + cloudsmith-oidc: ft-circleci-orbs/cloudsmith-oidc@1.0.0 aws-cli: circleci/aws-cli@3.1.4 serverless-framework: circleci/serverless-framework@2.0.2 diff --git a/orb/src/jobs/deploy-production.yml b/orb/src/jobs/deploy-production.yml index 978ddcfd9..6a83829cf 100644 --- a/orb/src/jobs/deploy-production.yml +++ b/orb/src/jobs/deploy-production.yml @@ -11,13 +11,30 @@ parameters: The system-code of the system being changed. Defaults to the repository name. type: string + cloudsmith-org: + default: 'financial-times' + type: string + cloudsmith-service-account: + default: '' + type: string executor: << parameters.executor >> +environment: + CLOUDSMITH_ORGANISATION: << parameters.cloudsmith-org >> + CLOUDSMITH_SERVICE_ACCOUNT: << parameters.cloudsmith-service-account >> + steps: - attach-workspace - setup_remote_docker: docker_layer_caching: true + - when: + condition: + and: + - << parameters.cloudsmith-org >> + - << parameters.cloudsmith-service-account >> + steps: + - cloudsmith-oidc/authenticate_with_oidc - when: condition: and: diff --git a/orb/src/jobs/deploy-review.yml b/orb/src/jobs/deploy-review.yml index 5de86b997..329260a04 100644 --- a/orb/src/jobs/deploy-review.yml +++ b/orb/src/jobs/deploy-review.yml @@ -8,13 +8,30 @@ parameters: system-code: default: '' type: string + cloudsmith-org: + default: 'financial-times' + type: string + cloudsmith-service-account: + default: '' + type: string executor: << parameters.executor >> +environment: + CLOUDSMITH_ORGANISATION: << parameters.cloudsmith-org >> + CLOUDSMITH_SERVICE_ACCOUNT: << parameters.cloudsmith-service-account >> + steps: - attach-workspace - setup_remote_docker: docker_layer_caching: true + - when: + condition: + and: + - << parameters.cloudsmith-org >> + - << parameters.cloudsmith-service-account >> + steps: + - cloudsmith-oidc/authenticate_with_oidc - when: condition: and: diff --git a/orb/src/jobs/deploy-staging.yml b/orb/src/jobs/deploy-staging.yml index b1749b2e7..5084dc3f3 100644 --- a/orb/src/jobs/deploy-staging.yml +++ b/orb/src/jobs/deploy-staging.yml @@ -2,13 +2,30 @@ parameters: executor: default: default type: executor + cloudsmith-org: + default: 'financial-times' + type: string + cloudsmith-service-account: + default: '' + type: string executor: << parameters.executor >> +environment: + CLOUDSMITH_ORGANISATION: << parameters.cloudsmith-org >> + CLOUDSMITH_SERVICE_ACCOUNT: << parameters.cloudsmith-service-account >> + steps: - attach-workspace - setup_remote_docker: docker_layer_caching: true + - when: + condition: + and: + - << parameters.cloudsmith-org >> + - << parameters.cloudsmith-service-account >> + steps: + - cloudsmith-oidc/authenticate_with_oidc - run: name: Deploy to staging command: npx dotcom-tool-kit deploy:staging diff --git a/plugins/circleci-deploy/.toolkitrc.yml b/plugins/circleci-deploy/.toolkitrc.yml index 2ce36e0c5..7a866dd8f 100644 --- a/plugins/circleci-deploy/.toolkitrc.yml +++ b/plugins/circleci-deploy/.toolkitrc.yml @@ -30,6 +30,10 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'deploy-staging' requires: - 'setup' @@ -39,6 +43,10 @@ options: filters: branches: only: main + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'e2e-test-review' requires: - 'deploy-review' @@ -71,6 +79,10 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'nightly' jobs: - name: 'deploy-review' @@ -85,6 +97,10 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' !toolkit/if-defined '@dotcom-tool-kit/circleci.cypressImage': executors: - name: cypress From f403c42b86d1f600a1fa2aa178082e238b64c5c1 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 21 Nov 2024 16:12:33 +0000 Subject: [PATCH 2/9] feat(cloudsmith): create plugin to allow us to set cloudsmith options Tool Kit will not allow you to declare options for plugins that don't exist (to avoid the likely case that there was a typo), but we want to declare Cloudsmith specific options that are used to generate CircleCI config. Declare a barebones plugin to facilitate this. --- package-lock.json | 22 ++++++++++++++---- plugins/circleci-deploy/.toolkitrc.yml | 1 + plugins/circleci-deploy/package.json | 1 + plugins/cloudsmith/.toolkitrc.yml | 1 + plugins/cloudsmith/package.json | 31 ++++++++++++++++++++++++++ plugins/cloudsmith/readme.md | 19 ++++++++++++++++ 6 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 plugins/cloudsmith/.toolkitrc.yml create mode 100644 plugins/cloudsmith/package.json create mode 100644 plugins/cloudsmith/readme.md diff --git a/package-lock.json b/package-lock.json index d43cb2ca7..e833bf6d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1093,6 +1093,7 @@ }, "core/sandbox": { "version": "1.0.0", + "extraneous": true, "license": "ISC", "workspaces": [ "packages/*" @@ -6449,6 +6450,10 @@ "resolved": "plugins/circleci-npm", "link": true }, + "node_modules/@dotcom-tool-kit/cloudsmith": { + "resolved": "plugins/cloudsmith", + "link": true + }, "node_modules/@dotcom-tool-kit/commitlint": { "resolved": "plugins/commitlint", "link": true @@ -25765,10 +25770,6 @@ "version": "2.1.2", "license": "MIT" }, - "node_modules/sandbox": { - "resolved": "core/sandbox", - "link": true - }, "node_modules/sax": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", @@ -30604,6 +30605,7 @@ "license": "ISC", "dependencies": { "@dotcom-tool-kit/circleci": "^7.0.2", + "@dotcom-tool-kit/cloudsmith": "^0.1.0", "tslib": "^2.3.1" }, "devDependencies": { @@ -30761,6 +30763,18 @@ "node": ">= 14" } }, + "plugins/cloudsmith": { + "name": "@dotcom-tool-kit/cloudsmith", + "version": "0.1.0", + "license": "ISC", + "engines": { + "node": "18.x || 20.x", + "npm": "7.x || 8.x || 9.x || 10.x" + }, + "peerDependencies": { + "dotcom-tool-kit": "4.x" + } + }, "plugins/commitlint": { "name": "@dotcom-tool-kit/commitlint", "version": "1.0.0", diff --git a/plugins/circleci-deploy/.toolkitrc.yml b/plugins/circleci-deploy/.toolkitrc.yml index 7a866dd8f..aa1bdef27 100644 --- a/plugins/circleci-deploy/.toolkitrc.yml +++ b/plugins/circleci-deploy/.toolkitrc.yml @@ -1,5 +1,6 @@ plugins: - '@dotcom-tool-kit/circleci' + - '@dotcom-tool-kit/cloudsmith' options: hooks: diff --git a/plugins/circleci-deploy/package.json b/plugins/circleci-deploy/package.json index c8d75dc5e..06dbf72f0 100644 --- a/plugins/circleci-deploy/package.json +++ b/plugins/circleci-deploy/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "@dotcom-tool-kit/circleci": "^7.2.0", + "@dotcom-tool-kit/cloudsmith": "^0.1.0", "tslib": "^2.3.1" }, "repository": { diff --git a/plugins/cloudsmith/.toolkitrc.yml b/plugins/cloudsmith/.toolkitrc.yml new file mode 100644 index 000000000..22817d2a9 --- /dev/null +++ b/plugins/cloudsmith/.toolkitrc.yml @@ -0,0 +1 @@ +version: 2 diff --git a/plugins/cloudsmith/package.json b/plugins/cloudsmith/package.json new file mode 100644 index 000000000..5f78fbb4f --- /dev/null +++ b/plugins/cloudsmith/package.json @@ -0,0 +1,31 @@ +{ + "name": "@dotcom-tool-kit/cloudsmith", + "version": "0.1.0", + "description": "", + "main": "lib", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "FT.com Platforms Team ", + "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/financial-times/dotcom-tool-kit.git", + "directory": "plugins/cloudsmith" + }, + "bugs": "https://github.com/financial-times/dotcom-tool-kit/issues", + "homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/plugins/cloudsmith", + "files": [ + "/lib", + ".toolkitrc.yml" + ], + "engines": { + "node": "18.x || 20.x", + "npm": "7.x || 8.x || 9.x || 10.x" + }, + "peerDependencies": { + "dotcom-tool-kit": "4.x" + } +} + diff --git a/plugins/cloudsmith/readme.md b/plugins/cloudsmith/readme.md new file mode 100644 index 000000000..3d50a8d89 --- /dev/null +++ b/plugins/cloudsmith/readme.md @@ -0,0 +1,19 @@ +# @dotcom-tool-kit/cloudsmith + +## Installation & Usage + +With Tool Kit [already set up](https://github.com/financial-times/dotcom-tool-kit#installing-and-using-tool-kit), install this plugin as a dev dependency: + +```sh +npm install --save-dev @dotcom-tool-kit/cloudsmith +``` + +And add it to your repo's `.toolkitrc.yml`: + +```yml +plugins: + - '@dotcom-tool-kit/cloudsmith' +``` + + + From 6bba806e73f48e9b36bf7e3391a42f1a3eb05096 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 21 Nov 2024 16:31:54 +0000 Subject: [PATCH 3/9] feat(cloudsmith): move cloudsmith CircleCI config into plugin Tool Kit will be able to merge the additional custom CircleCI config into the configuration already defined by the circleci-deploy plugin. This will allow users to explicitly opt into the cloudsmith logic by installing the plugin, and compartmentalises the configuration. --- package-lock.json | 1 - plugins/circleci-deploy/.toolkitrc.yml | 17 ------------ plugins/circleci-deploy/package.json | 1 - plugins/cloudsmith/.toolkitrc.yml | 36 ++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index e833bf6d7..19165713b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30605,7 +30605,6 @@ "license": "ISC", "dependencies": { "@dotcom-tool-kit/circleci": "^7.0.2", - "@dotcom-tool-kit/cloudsmith": "^0.1.0", "tslib": "^2.3.1" }, "devDependencies": { diff --git a/plugins/circleci-deploy/.toolkitrc.yml b/plugins/circleci-deploy/.toolkitrc.yml index aa1bdef27..2ce36e0c5 100644 --- a/plugins/circleci-deploy/.toolkitrc.yml +++ b/plugins/circleci-deploy/.toolkitrc.yml @@ -1,6 +1,5 @@ plugins: - '@dotcom-tool-kit/circleci' - - '@dotcom-tool-kit/cloudsmith' options: hooks: @@ -31,10 +30,6 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': - cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'deploy-staging' requires: - 'setup' @@ -44,10 +39,6 @@ options: filters: branches: only: main - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': - cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'e2e-test-review' requires: - 'deploy-review' @@ -80,10 +71,6 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': - cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'nightly' jobs: - name: 'deploy-review' @@ -98,10 +85,6 @@ options: !toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId': aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId' system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': - cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' !toolkit/if-defined '@dotcom-tool-kit/circleci.cypressImage': executors: - name: cypress diff --git a/plugins/circleci-deploy/package.json b/plugins/circleci-deploy/package.json index 06dbf72f0..c8d75dc5e 100644 --- a/plugins/circleci-deploy/package.json +++ b/plugins/circleci-deploy/package.json @@ -11,7 +11,6 @@ "license": "ISC", "dependencies": { "@dotcom-tool-kit/circleci": "^7.2.0", - "@dotcom-tool-kit/cloudsmith": "^0.1.0", "tslib": "^2.3.1" }, "repository": { diff --git a/plugins/cloudsmith/.toolkitrc.yml b/plugins/cloudsmith/.toolkitrc.yml index 22817d2a9..d1ab236b3 100644 --- a/plugins/cloudsmith/.toolkitrc.yml +++ b/plugins/cloudsmith/.toolkitrc.yml @@ -1 +1,37 @@ version: 2 + +plugins: + - '@dotcom-tool-kit/circleci-deploy' + +options: + hooks: + - CircleCi: + workflows: + - name: 'tool-kit' + jobs: + - name: 'deploy-review' + custom: + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' + - name: 'deploy-staging' + custom: + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' + - name: 'deploy-production' + custom: + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' + - name: 'nightly' + jobs: + - name: 'deploy-review' + custom: + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': + cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': + cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' From 324293de840e56e537a6b2c468555f42e94ad9b2 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 21 Nov 2024 16:33:26 +0000 Subject: [PATCH 4/9] backstage: update create-plugin script with latest package.json values --- scripts/create-plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/create-plugin.js b/scripts/create-plugin.js index f33e804ed..237d8c15b 100755 --- a/scripts/create-plugin.js +++ b/scripts/create-plugin.js @@ -36,10 +36,10 @@ pkg.author = 'FT.com Platforms Team ' pkg.files = ['/lib', '.toolkitrc.yml'] pkg.engines = { node: '18.x || 20.x', - npm: '7.x || 8.x || 9.x' + npm: '7.x || 8.x || 9.x || 10.x' } pkg.peerDependencies = { - 'dotcom-tool-kit': '3.x' + 'dotcom-tool-kit': '4.x' } fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)) From 146ddf52eea1a86561f070bdbe3d932bde21cde5 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Tue, 3 Dec 2024 17:25:12 +0000 Subject: [PATCH 5/9] backstage: update create-plugin script to include README This is primarily so that our git hook can automatically fill in autogenerated docs where appropriate. --- scripts/create-plugin.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/create-plugin.js b/scripts/create-plugin.js index 237d8c15b..b782ece2b 100755 --- a/scripts/create-plugin.js +++ b/scripts/create-plugin.js @@ -64,6 +64,31 @@ fs.writeFileSync('tsconfig.json', JSON.stringify(tsconfig, null, 2)) console.log('📄 adding empty toolkit config') fs.writeFileSync('.toolkitrc.yml', 'version: 2\n') +console.log('📖 adding simple README') +fs.writeFileSync( + 'readme.md', + `#dotcom-tool-kit/${name} + +## Installation & Usage + +With Tool Kit [already set up](https://github.com/financial-times/dotcom-tool-kit#installing-and-using-tool-kit), install this plugin as a dev dependency: + +\`\`\`sh +npm install --save-dev @dotcom-tool-kit/${name} +\`\`\` + +And add it to your repo's \`.toolkitrc.yml\`: + +\`\`\`yml +plugins: + - '@dotcom-tool-kit/${name}' +\`\`\` + + + +` +) + console.log('🔗 adding reference to root tsconfig') const rootTsconfig = JSON.parse(fs.readFileSync('../../tsconfig.json')) rootTsconfig.references.push({ path: directory }) From 55efc14bafefbaa4f49c9aafc3e06f800dd5987a Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Tue, 3 Dec 2024 17:28:17 +0000 Subject: [PATCH 6/9] docs: automatically regenerate schema docs --- plugins/cloudsmith/readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/cloudsmith/readme.md b/plugins/cloudsmith/readme.md index 3d50a8d89..2a991fe63 100644 --- a/plugins/cloudsmith/readme.md +++ b/plugins/cloudsmith/readme.md @@ -16,4 +16,14 @@ plugins: ``` +## Plugin-wide options + +### `@dotcom-tool-kit/cloudsmith` + +| Property | Description | Type | +| :--------------- | :----------------------------- | :------- | +| `organisation` | the Cloudsmith organisation | `string` | +| `serviceAccount` | the Cloudsmith service account | `string` | + +_All properties are optional._ From 117c3b74fc566b89c7247acc8207ef6af462c640 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 5 Dec 2024 13:57:29 +0000 Subject: [PATCH 7/9] feat(cloudsmith): hardcode Cloudsmith organisation We'll likely never the flexibility to set a different organisation. Co-Authored-By: Rowan Manning --- lib/schemas/src/plugins/cloudsmith.ts | 1 - plugins/cloudsmith/.toolkitrc.yml | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/schemas/src/plugins/cloudsmith.ts b/lib/schemas/src/plugins/cloudsmith.ts index 10510db80..fd4cb4894 100644 --- a/lib/schemas/src/plugins/cloudsmith.ts +++ b/lib/schemas/src/plugins/cloudsmith.ts @@ -1,6 +1,5 @@ import { z } from 'zod' export const CloudsmithSchema = z.object({ - organisation: z.string().optional().describe('the Cloudsmith organisation'), serviceAccount: z.string().optional().describe('the Cloudsmith service account') }) diff --git a/plugins/cloudsmith/.toolkitrc.yml b/plugins/cloudsmith/.toolkitrc.yml index d1ab236b3..8ac1e05a0 100644 --- a/plugins/cloudsmith/.toolkitrc.yml +++ b/plugins/cloudsmith/.toolkitrc.yml @@ -11,27 +11,23 @@ options: jobs: - name: 'deploy-review' custom: - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + cloudsmith-org: financial-times !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'deploy-staging' custom: - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + cloudsmith-org: financial-times !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'deploy-production' custom: - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + cloudsmith-org: financial-times !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' - name: 'nightly' jobs: - name: 'deploy-review' custom: - !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation': - cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation' + cloudsmith-org: financial-times !toolkit/if-defined '@dotcom-tool-kit/cloudsmith.serviceAccount': cloudsmith-service-account: !toolkit/option '@dotcom-tool-kit/cloudsmith.serviceAccount' From 4c4295d00f481685b380d4480e83eaa787ebc3d1 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 5 Dec 2024 13:58:28 +0000 Subject: [PATCH 8/9] docs(cloudsmith): clarify Cloudsmith service account setting --- lib/schemas/src/plugins/cloudsmith.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/schemas/src/plugins/cloudsmith.ts b/lib/schemas/src/plugins/cloudsmith.ts index fd4cb4894..20791837b 100644 --- a/lib/schemas/src/plugins/cloudsmith.ts +++ b/lib/schemas/src/plugins/cloudsmith.ts @@ -1,5 +1,10 @@ import { z } from 'zod' export const CloudsmithSchema = z.object({ - serviceAccount: z.string().optional().describe('the Cloudsmith service account') + serviceAccount: z + .string() + .optional() + .describe( + 'the Cloudsmith service account. this will probably be your team name followed by the permissions access, e.g., cp-reliability-read-write.' + ) }) From 68923bd107712e06bd60301adca2ee2d7d3ccebc Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 5 Dec 2024 13:59:33 +0000 Subject: [PATCH 9/9] docs: automatically regenerate schema docs --- plugins/cloudsmith/readme.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/cloudsmith/readme.md b/plugins/cloudsmith/readme.md index 2a991fe63..051cc18c0 100644 --- a/plugins/cloudsmith/readme.md +++ b/plugins/cloudsmith/readme.md @@ -20,10 +20,9 @@ plugins: ### `@dotcom-tool-kit/cloudsmith` -| Property | Description | Type | -| :--------------- | :----------------------------- | :------- | -| `organisation` | the Cloudsmith organisation | `string` | -| `serviceAccount` | the Cloudsmith service account | `string` | +| Property | Description | Type | +| :--------------- | :---------------------------------------------------------------------------------------------------------------------------------------- | :------- | +| `serviceAccount` | the Cloudsmith service account. this will probably be your team name followed by the permissions access, e.g., cp-reliability-read-write. | `string` | _All properties are optional._