From a1a490948293ee780c16ade65c0f46f735d97f63 Mon Sep 17 00:00:00 2001 From: Jack Stevenson Date: Thu, 1 Feb 2024 15:34:37 +1100 Subject: [PATCH] build: update projen version as part of upgrade workflow (#695) Adds a task to run as part of the upgrade-mainline workflow which updates the projen version such that PDK and its vended projects all depend on the same projen version. --- .github/workflows/upgrade-mainline.yml | 2 ++ packages/monorepo/.projen/tasks.json | 8 ++++++++ packages/monorepo/package.json | 1 + packages/monorepo/project.json | 7 +++++++ packages/monorepo/scripts/upgrade-projen.ts | 15 +++++++++++++++ projenrc/projects/monorepo-project.ts | 3 +++ 6 files changed, 36 insertions(+) create mode 100644 packages/monorepo/scripts/upgrade-projen.ts diff --git a/.github/workflows/upgrade-mainline.yml b/.github/workflows/upgrade-mainline.yml index 179ddd4a1..8c9c02b03 100644 --- a/.github/workflows/upgrade-mainline.yml +++ b/.github/workflows/upgrade-mainline.yml @@ -20,6 +20,8 @@ jobs: ref: mainline - name: PDK Init uses: ./.github/actions/pdk-init + - name: Upgrade projen + run: pnpm nx run @aws/monorepo:upgrade-projen - name: Upgrade dependencies run: pnpm projen upgrade-deps - name: Build diff --git a/packages/monorepo/.projen/tasks.json b/packages/monorepo/.projen/tasks.json index c22589604..a3b3482c8 100644 --- a/packages/monorepo/.projen/tasks.json +++ b/packages/monorepo/.projen/tasks.json @@ -183,6 +183,14 @@ } ] }, + "upgrade-projen": { + "name": "upgrade-projen", + "steps": [ + { + "exec": "ts-node ./scripts/upgrade-projen.ts" + } + ] + }, "watch": { "name": "watch", "description": "Watch & compile in the background", diff --git a/packages/monorepo/package.json b/packages/monorepo/package.json index 83d830d83..48c2b9e52 100644 --- a/packages/monorepo/package.json +++ b/packages/monorepo/package.json @@ -25,6 +25,7 @@ "pre-compile": "pnpm exec projen pre-compile", "test": "pnpm exec projen test", "test:watch": "pnpm exec projen test:watch", + "upgrade-projen": "pnpm exec projen upgrade-projen", "watch": "pnpm exec projen watch" }, "author": { diff --git a/packages/monorepo/project.json b/packages/monorepo/project.json index 4c3b9c241..64db91a46 100644 --- a/packages/monorepo/project.json +++ b/packages/monorepo/project.json @@ -141,6 +141,13 @@ "command": "pnpm exec projen docgen", "cwd": "packages/monorepo" } + }, + "upgrade-projen": { + "executor": "nx:run-commands", + "options": { + "command": "pnpm exec projen upgrade-projen", + "cwd": "packages/monorepo" + } } }, "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"." diff --git a/packages/monorepo/scripts/upgrade-projen.ts b/packages/monorepo/scripts/upgrade-projen.ts new file mode 100644 index 000000000..5fb31226c --- /dev/null +++ b/packages/monorepo/scripts/upgrade-projen.ts @@ -0,0 +1,15 @@ +import * as ncu from "npm-check-updates"; +import * as fs from "fs"; +import * as path from "path"; + +(async () => { + // Get the latest minor version update of projen + const { projen } = await ncu.run({ + jsonUpgraded: true, + target: "minor", + filter: "projen", + }) as any; + + // Write the projen version to projen-version.ts + fs.writeFileSync(path.resolve(__dirname, "../src/components/projen-version.ts"), `export default "^${projen}";`); +})(); diff --git a/projenrc/projects/monorepo-project.ts b/projenrc/projects/monorepo-project.ts index 3dafdc4a1..5ac89c76f 100644 --- a/projenrc/projects/monorepo-project.ts +++ b/projenrc/projects/monorepo-project.ts @@ -51,6 +51,9 @@ export class MonorepoProject extends PDKProject { // Don't check for a license header etc for projen-version.ts so this can be written via automation this.eslint?.addIgnorePattern("src/components/projen-version.ts"); + // Add a task to upgrade the projen version. Ideally run before upgrade-deps in the root. + this.addTask("upgrade-projen").exec("ts-node ./scripts/upgrade-projen.ts") + this.generateInterfaces(); }