diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 4459023375d0a..2826bb43a64a1 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -139,3 +139,6 @@ Owner: CDK Support team [project-prioritization-added-on.yml](project-prioritization-added-on.yml): GitHub action that runs every day to update AddedOn field in the prioritization project board. Owner: CDK Support team + +### Issue sync +[issue-sync.yml](issue-sync.yml): Github action that syncs issue metadat with the project board. More details can be found on the [project-sync](../../tools/@aws-cdk/project-sync) package. diff --git a/.github/workflows/issue-sync.yml b/.github/workflows/issue-sync.yml new file mode 100644 index 0000000000000..f33c328296440 --- /dev/null +++ b/.github/workflows/issue-sync.yml @@ -0,0 +1,68 @@ +name: Issue Sync + +on: + issue_comment: + types: [created, edited, deleted] + issues: + types: [opened] + +jobs: + sync-issue: + name: Sync Issue with Project Board + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: 'tools/@aws-cdk/project-sync/yarn.lock' + + # Cache node_modules + - name: Cache node_modules + uses: actions/cache@v3 + id: cache-modules + with: + path: | + tools/@aws-cdk/project-sync/node_modules + node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('tools/@aws-cdk/project-sync/yarn.lock', 'yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install dependencies + if: steps.cache-modules.outputs.cache-hit != 'true' + run: | + cd tools/@aws-cdk/project-sync + yarn install --frozen-lockfile + + # Cache build output + - name: Cache build output + uses: actions/cache@v3 + id: cache-build + with: + path: | + tools/@aws-cdk/project-sync/lib/*.js + tools/@aws-cdk/project-sync/bin/*.js + key: ${{ runner.os }}-build-${{ hashFiles('tools/@aws-cdk/project-sync/lib', 'tools/@aws-cdk/project-sync/bin') }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Build project-sync + if: steps.cache-build.outputs.cache-hit != 'true' + run: | + cd tools/@aws-cdk/project-sync + yarn build + + - name: Run issue-sync + env: + GITHUB_TOKEN: ${{ secrets.PROJECT_SYNC_GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY: ${{ github.repository }} + PROJECT_NUMBER: ${{ vars.PROJECT_NUMBER || 302 }} + run: | + cd tools/@aws-cdk/project-sync + node bin/issue-sync.js diff --git a/package.json b/package.json index e95b12a40c468..c77e9021708cf 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "tools/@aws-cdk/prlint", "tools/@aws-cdk/spec2cdk", "tools/@aws-cdk/lazify", + "tools/@aws-cdk/project-sync", "tools/@aws-cdk/lambda-integration-test-updater", "tools/@aws-cdk/construct-metadata-updater", "scripts/@aws-cdk/script-tests" diff --git a/tools/@aws-cdk/project-sync/.eslintrc.js b/tools/@aws-cdk/project-sync/.eslintrc.js new file mode 100644 index 0000000000000..418bc19b0adf2 --- /dev/null +++ b/tools/@aws-cdk/project-sync/.eslintrc.js @@ -0,0 +1,17 @@ +const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc'); +baseConfig.parserOptions.project = __dirname + '/tsconfig.json'; + +baseConfig.rules['import/no-extraneous-dependencies'] = ['error', { devDependencies: true, peerDependencies: true } ]; +baseConfig.rules['import/order'] = 'off'; +baseConfig.rules['@aws-cdk/invalid-cfn-imports'] = 'off'; +baseConfig.rules['@cdklabs/no-throw-default-error'] = ['error']; +baseConfig.overrides.push({ + files: ["./test/**"], + rules: { + "@typescript-eslint/unbound-method": "off" + }, +}); +baseConfig.rules['no-console'] = 'off' +baseConfig.rules['@cdklabs/no-throw-default-error'] = 'off' + +module.exports = baseConfig; \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/.gitignore b/tools/@aws-cdk/project-sync/.gitignore new file mode 100644 index 0000000000000..bef31def37928 --- /dev/null +++ b/tools/@aws-cdk/project-sync/.gitignore @@ -0,0 +1,15 @@ +*.js +*.js.map +*.d.ts +dist + +.LAST_BUILD +*.snk +!jest.config.js + +.nyc_output +coverage +nyc.config.js +!.eslintrc.js +!test/test-fixture/jsii/node_modules/ +junit.xml diff --git a/tools/@aws-cdk/project-sync/LICENSE b/tools/@aws-cdk/project-sync/LICENSE new file mode 100644 index 0000000000000..eb98d22ca8d4b --- /dev/null +++ b/tools/@aws-cdk/project-sync/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/tools/@aws-cdk/project-sync/README.md b/tools/@aws-cdk/project-sync/README.md new file mode 100644 index 0000000000000..689e2ad749129 --- /dev/null +++ b/tools/@aws-cdk/project-sync/README.md @@ -0,0 +1,93 @@ +# CDK Projects Issue Sync + +This tool helps maintain the GitHub project board by automatically updating custom fields with issue creation and update dates. This includes addressing the limitation where GitHub Projects doesn't automatically track when issues were last meaningfully updated. + +## Features + +- Synchronize individual issues metadata with the project board +- Batch synchronize all issues metadata in a project + +## Prerequisites + +- Node.js and npm/yarn +- GitHub Token with access to the AWS CDK repository and the project board. + +## Environment Variables + +The tool requires the following environment variables: + +- `GITHUB_TOKEN`: GitHub personal access token +- `PROJECT_NUMBER`: The GitHub project number +- `ISSUE_NUMBER`: Required when syncing a single issue + +## Installation + +```bash +# Clone the repository (if not already done) +git clone https://github.com/aws/aws-cdk.git +cd aws-cdk/tools/@aws-cdk/project-sync + +# Install dependencies +yarn install +``` + +## Usage + +### Sync a Single Issue + +```bash +# Set required environment variables +export GITHUB_TOKEN=secret_github_token +export ISSUE_NUMBER=12345 + +# Run the sync +yarn run build && node bin/issue-sync.js +``` + +### Sync All Issues in a Project + +```bash +# Set required environment variables +export GITHUB_TOKEN=secret_github_token +export PROJECT_NUMBER=302 # Optional, defaults to 302 + +# Run the sync for all issues +yarn issue-sync-all +``` + +## How It Works + +1. The tool fetches issue details from GitHub using the GraphQL API +2. For each issue, it: + - Determines if the issue is part of the specified project + - Extracts issue metadata including creation and update date + - Updates the corresponding custom fields in the GitHub Project with those dates. + +## Development + +### Build +```bash +# Build the project +yarn build +``` + +### Test + +#### Snapshots +This package uses snapshots of the API requests to test against. These snaphsots are generated via: + +``` +yarn run gen-snapshots +``` + +Which runs the scripts defined in `test/snapshots/generate.js`. + +#### Run tests + +``` +yarn test +``` + +## License + +Apache-2.0 diff --git a/tools/@aws-cdk/project-sync/bin/issue-sync-all.ts b/tools/@aws-cdk/project-sync/bin/issue-sync-all.ts new file mode 100644 index 0000000000000..eacd4df910f42 --- /dev/null +++ b/tools/@aws-cdk/project-sync/bin/issue-sync-all.ts @@ -0,0 +1,3 @@ +import { syncAllIssues } from '../lib/issue-sync-all.js'; + +syncAllIssues().catch(console.error); diff --git a/tools/@aws-cdk/project-sync/bin/issue-sync.ts b/tools/@aws-cdk/project-sync/bin/issue-sync.ts new file mode 100644 index 0000000000000..40ed076b21f69 --- /dev/null +++ b/tools/@aws-cdk/project-sync/bin/issue-sync.ts @@ -0,0 +1,5 @@ +import { syncIssue } from '../lib/issue-sync'; + +if (process.env.ISSUE_NUMBER === undefined) {throw Error('Environment variable ISSUE_NUMBER is not defined');} + +syncIssue(process.env.ISSUE_NUMBER).then(console.log).catch(console.error); diff --git a/tools/@aws-cdk/project-sync/jest.config.js b/tools/@aws-cdk/project-sync/jest.config.js new file mode 100644 index 0000000000000..9a7e1a9cb0b61 --- /dev/null +++ b/tools/@aws-cdk/project-sync/jest.config.js @@ -0,0 +1,2 @@ +const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); +module.exports = baseConfig; \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/lib/config.ts b/tools/@aws-cdk/project-sync/lib/config.ts new file mode 100644 index 0000000000000..1c8eddcc1c45b --- /dev/null +++ b/tools/@aws-cdk/project-sync/lib/config.ts @@ -0,0 +1,2 @@ +export const PROJECT_NUMBER = process.env.PROJECT_NUMBER || '302'; +export const [REPOSITORY_OWNER, REPOSITORY] = (process.env.REPOSITORY || 'aws/aws-cdk').split('/') ; diff --git a/tools/@aws-cdk/project-sync/lib/github.ts b/tools/@aws-cdk/project-sync/lib/github.ts new file mode 100644 index 0000000000000..2ecc91ba8f3e3 --- /dev/null +++ b/tools/@aws-cdk/project-sync/lib/github.ts @@ -0,0 +1,187 @@ +import { REPOSITORY, REPOSITORY_OWNER } from './config'; + +const issueQuery = ` + createdAt + timelineItems(last: 100) { + nodes{ + ... on IssueComment { + createdAt + author { + login + } + } + ... on CrossReferencedEvent { + createdAt + actor { + login + } + } + ... on ClosedEvent { + createdAt + actor { + login + } + } + ... on ReopenedEvent { + createdAt + actor { + login + } + } + ... on LabeledEvent { + createdAt + actor { + login + } + } + ... on UnlabeledEvent { + createdAt + actor { + login + } + } + ... on AssignedEvent { + createdAt + actor { + login + } + } + ... on UnassignedEvent { + createdAt + actor { + login + } + } + } + } + reactions(last: 1) { + nodes { + createdAt + } + } + projectItems(first: 100) { + nodes { + id + project { + number + } + } + } +`; + +export class Github { + static default(): Github { + if (!process.env.GITHUB_TOKEN) { + throw new Error('GITHUB_TOKEN is not set'); + } + + return new Github(process.env.GITHUB_TOKEN); + } + + token: string; + + constructor(token: string) { + this.token = token; + } + + async authGraphQL(query: string) { + const response = await fetch('https://api.github.com/graphql', { + method: 'POST', + headers: { + 'Authorization': `token ${this.token}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ query }), + }); + + if (!response.ok) { + throw new Error(`GitHub GraphQL request failed: ${response.statusText}`); + } + + return response.json(); + } + + getProjectIssues(project: string, cursor?: string) { + return this.authGraphQL(` + query { + repository(owner: "${REPOSITORY_OWNER}", name: "${REPOSITORY}") { + projectV2(number: ${project}) { + items(first: 100 ${cursor ? `, after: "${cursor}"` : ''}) { + pageInfo { + hasNextPage + endCursor + } + nodes { + content { + ... on Issue { + number + title + ${issueQuery} + } + } + } + } + } + } + } + `); + } + + getProjectInfo(project: string) { + return this.authGraphQL(` + query { + repository(owner: "${REPOSITORY_OWNER}", name: "${REPOSITORY}") { + projectV2(number: ${project}) { + id + fields(first: 100) { + nodes { + ... on ProjectV2Field { + id + name + } + } + } + } + } + } + `); + } + + getIssue(issue: string) { + return this.authGraphQL(` + query { + repository(owner: "${REPOSITORY_OWNER}", name: "${REPOSITORY}") { + issue(number: ${issue}) { + ${issueQuery} + } + } + } + `); + } + + async setProjectItem(projectId: string, itemId: string, fields: Record< + string, + {date: Date} | {text: string} | {number: number} | {singleSelectOptionId: string} | {iterationId: string} + >) { + const results = []; + for (const [key, value] of Object.entries(fields)) { + results.push(await this.authGraphQL(` + mutation { + updateProjectV2ItemFieldValue( + input: { + projectId: "${projectId}", + itemId: "${itemId}", + fieldId: "${key}", + value: {${Object.entries(value).map(([fieldKey, fieldValue]) => `${fieldKey}: ${JSON.stringify(fieldValue)}`).join(',')}} + } + ) { + projectV2Item { + id + } + } + } + `)); + } + return results; + } +} diff --git a/tools/@aws-cdk/project-sync/lib/issue-sync-all.ts b/tools/@aws-cdk/project-sync/lib/issue-sync-all.ts new file mode 100644 index 0000000000000..de475ab0d3ec6 --- /dev/null +++ b/tools/@aws-cdk/project-sync/lib/issue-sync-all.ts @@ -0,0 +1,58 @@ +import { PROJECT_NUMBER } from './config'; +import { Github } from './github'; +import { syncIssueData } from './issue-sync'; + +export async function syncAllIssues() { + try { + const github = Github.default(); + + console.log(`Fetching all issues from project ${PROJECT_NUMBER}...`); + + let hasNextPage = true; + let cursor: string | undefined = undefined; + let issueCounter = 0; + + // Use pagination to fetch all issues from project + while (hasNextPage) { + const response = await github.getProjectIssues(PROJECT_NUMBER, cursor); + + if (!response.data?.repository?.projectV2?.items?.nodes) { + console.error('Failed to fetch project items or no items found'); + break; + } + + const pageInfo = response.data.repository.projectV2.items.pageInfo; + hasNextPage = pageInfo.hasNextPage; + cursor = pageInfo.endCursor; + + // Extract issues from project items + const projectItems = response.data.repository.projectV2.items.nodes; + const issues = projectItems + .filter((item: any) => item.content?.number != undefined) + .map((item: any) => item.content); + + console.log(`Fetched page with ${projectItems.length} project items, found ${issues.length} issues`); + issueCounter += issues.length; + + // Process each issue sequentially + for (const issue of issues) { + const issueNumber = issue.number.toString(); + console.log(`Processing issue #${issueNumber}: ${issue.title}`); + + try { + await syncIssueData(issue); + console.log(`Successfully synced issue #${issueNumber}`); + } catch (error) { + console.error(`Error syncing issue #${issueNumber}:`, error); + } + + // Add a small delay between requests to avoid hitting rate limits + await new Promise(resolve => setTimeout(resolve, 1000)); + } + } + + console.log(`Finished syncing ${issueCounter} issue(s) from project 302`); + } catch (error) { + console.error('Error in syncAllIssues:', error); + } +} diff --git a/tools/@aws-cdk/project-sync/lib/issue-sync.ts b/tools/@aws-cdk/project-sync/lib/issue-sync.ts new file mode 100644 index 0000000000000..d5fc315b33785 --- /dev/null +++ b/tools/@aws-cdk/project-sync/lib/issue-sync.ts @@ -0,0 +1,88 @@ +import { Github } from './github.js'; +import { PROJECT_NUMBER, REPOSITORY } from './config.js'; + +export const syncIssue = async (issue: string) => { + const github = Github.default(); + + // 1. Fetch the issue details + const issueData = await github.getIssue(issue) as Record; + + // Extract repository data + const repoData = issueData?.data?.repository; + if (!repoData || !repoData.issue) { + throw new Error(`Issue ${issue} not found on repository ${REPOSITORY}`); + } + + await syncIssueData(repoData.issue); +}; + +export const syncIssueData = async (issueDetails: any) => { + const github = Github.default(); + + // If issue is part of the project, set the issue's project properties + let projectItemId = undefined; + if (issueDetails.projectItems?.nodes) { + for (const node of issueDetails.projectItems.nodes) { + if (`${node.project?.number}` === PROJECT_NUMBER) { + projectItemId = node.id; + break; + } + } + } + + if (projectItemId === undefined) { + console.log(`Issue is not included in project ${PROJECT_NUMBER}, skipping.`); + return; + } + + const projectInfo = await github.getProjectInfo(PROJECT_NUMBER); + const projectId = projectInfo.data.repository.projectV2.id!; + + let createFieldId = undefined; + let updateFieldId = undefined; + for (const field of projectInfo.data.repository.projectV2.fields.nodes) { + if (field.name === 'Create date') { + createFieldId = field.id; + } + if (field.name === 'Update date') { + updateFieldId = field.id; + } + } + + if (createFieldId === undefined) { + throw new Error('Project field "Creation date" not found'); + } + + if (updateFieldId === undefined) { + throw new Error('Project field "Update date" not found'); + } + + // Get timeline items to determine the last update date (excluding github-actions) + const timelineItems = issueDetails.timelineItems?.nodes ?? []; + + // Get creation date from the first reaction or use current date + const creationDate = new Date(issueDetails.createdAt); + + // Get update date from the last timeline item or use creation date + let updateDate = creationDate; + + for (let index = 0; index < timelineItems.length; index++) { + const item = timelineItems[timelineItems.length-index-1]; + if (item?.createdAt !== undefined && item.author?.login !== 'github-actions' && item.actor?.login !== 'github-actions') { + updateDate = new Date(item.createdAt); + break; + } + } + + if (issueDetails.reactions.nodes.length > 0) { + const reactionDate = new Date(issueDetails.reactions.nodes[0].createdAt); + if (reactionDate > updateDate) {updateDate = reactionDate;} + } + + const result = await github.setProjectItem(projectId, projectItemId, { + [createFieldId]: { date: creationDate }, + [updateFieldId]: { date: updateDate }, + }); + console.log('Result from mutation request: '); + console.dir(JSON.stringify(result)); +}; diff --git a/tools/@aws-cdk/project-sync/package.json b/tools/@aws-cdk/project-sync/package.json new file mode 100644 index 0000000000000..c673edca1f6cd --- /dev/null +++ b/tools/@aws-cdk/project-sync/package.json @@ -0,0 +1,28 @@ +{ + "name": "@aws-cdk/project-sync", + "version": "0.0.0", + "private": true, + "bin": { + "project-sync": "bin/project-sync.ts" + }, + "scripts": { + "build": "tsc --build", + "build+test": "npm run build && npm run test", + "lint": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern lib bin test", + "package": "mkdir -p dist/js && mv $(npm pack) dist/js/", + "test": "jest --passWithNoTests --updateSnapshot --coverage=false", + "test:watch": "jest --watch", + "watch": "tsc --build -w tsconfig.json", + "gen-snapshots": "yarn run build && node test/snapshots/generate.js", + "issue-sync-all": "yarn run build && node bin/issue-sync-all.js" + }, + "dependencies": { + "@aws-cdk/cdk-build-tools": "0.0.0", + "@jest/globals": "^30.0.0", + "jest": "^29", + "ts-jest": "^29.4.0", + "typescript": "~5.5.4" + }, + "main": "bin/project-sync.js", + "license": "Apache-2.0" +} diff --git a/tools/@aws-cdk/project-sync/test/github-mock.ts b/tools/@aws-cdk/project-sync/test/github-mock.ts new file mode 100644 index 0000000000000..0f8a78c036804 --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/github-mock.ts @@ -0,0 +1,34 @@ +import * as fs from 'node:fs/promises'; +import { join } from 'node:path'; + +export class GithubMock { + token: string; + + constructor(token: string) { + this.token = token; + } + + authGraphQL(_query: string) : Promise { + throw Error('Not implemented in the mock.'); + } + + async getProjectInfo(_projectId: string) { + return JSON.parse((await fs.readFile(join(__dirname, 'snapshots', 'get-project-info.json'))).toString()); + } + + async getIssue(issue: string) { + return JSON.parse((await fs.readFile(join(__dirname, 'snapshots', 'get-issue', `${issue}.json`))).toString()); + } + + async setProjectItem(_projectId: string, _itemId: string, _fields: Record< + string, + {date: Date} | {text: string} | {number: number} | {singleSelectOptionId: string} | {iterationId: string} + >): Promise { + // Mock implementation that just returns success + return { success: true }; + } + + queryIssues(_labels: string[], _state: 'OPEN' | 'CLOSED' | 'ALL' = 'OPEN', _cursor?: string): Promise { + throw Error('Not implemented in the mock.'); + } +} diff --git a/tools/@aws-cdk/project-sync/test/issue-sync.test.ts b/tools/@aws-cdk/project-sync/test/issue-sync.test.ts new file mode 100644 index 0000000000000..8df5f127d1b9e --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/issue-sync.test.ts @@ -0,0 +1,67 @@ +import { describe, test, expect, jest, beforeEach } from '@jest/globals'; +import * as issueSync from '../lib/issue-sync.js'; +import { GithubMock } from './github-mock.js'; +import { Github } from '../lib/github.js'; + +jest.mock('../lib/github.js'); + +describe('Issue Sync', () => { + let mockGithub: GithubMock; + + beforeEach(() => { + // Create a new instance of our mock GitHub client + mockGithub = new GithubMock('fake-token'); + (Github.default as jest.Mock).mockReturnValue(mockGithub); + + // Spy on the setProjectItem method to verify calls + jest.spyOn(mockGithub, 'setProjectItem'); + jest.spyOn(mockGithub, 'getProjectInfo'); + }); + + test('syncIssue fetches issue details and sets project item fields', async () => { + // The test will use the existing snapshot file for issue 15891 + await issueSync.syncIssue('15891'); + + expect(mockGithub.getProjectInfo).toHaveBeenCalledWith('302'); + + // Verify that setProjectItem was called with the project item ID from the snapshot + // and the expected creation and update dates + expect(mockGithub.setProjectItem).toHaveBeenCalledWith('PVT_kwDOACIPmc4A7TlP', 'PVTI_lADOACIPmc4A7TlPzgbanR8', { + PVTF_lADOACIPmc4A7TlPzgvqxXA: { date: new Date('2021-08-04T15:40:27Z') }, + PVTF_lADOACIPmc4A7TlPzgv350s: { date: new Date('2025-05-02T15:55:16Z') }, + }); + }); + + test('syncIssue fetches issue details and sets project item fields #2', async () => { + // The test will use the existing snapshot file for issue 15891 + await issueSync.syncIssue('30793'); + + expect(mockGithub.getProjectInfo).toHaveBeenCalledWith('302'); + + // Verify that setProjectItem was called with the project item ID from the snapshot + // and the expected creation and update dates + expect(mockGithub.setProjectItem).toHaveBeenCalledWith('PVT_kwDOACIPmc4A7TlP', 'PVTI_lADOACIPmc4A7TlPzgbamKo', { + PVTF_lADOACIPmc4A7TlPzgvqxXA: { date: new Date('2024-07-09T08:10:25Z') }, + PVTF_lADOACIPmc4A7TlPzgv350s: { date: new Date('2025-05-26T15:43:23Z') }, + }); + }); + + test('syncIssue skips event from github-actions', async () => { + // The test will use the existing snapshot file for issue 15891 + await issueSync.syncIssue('33208'); + + expect(mockGithub.getProjectInfo).toHaveBeenCalledWith('302'); + + // Verify that setProjectItem was called with the project item ID from the snapshot + // and the expected creation and update dates + expect(mockGithub.setProjectItem).toHaveBeenCalledWith('PVT_kwDOACIPmc4A7TlP', 'PVTI_lADOACIPmc4A7TlPzgbamBo', { + PVTF_lADOACIPmc4A7TlPzgvqxXA: { date: new Date('2025-01-28T09:56:52Z') }, + PVTF_lADOACIPmc4A7TlPzgv350s: { date: new Date('2025-06-12T16:00:02Z') }, + }); + }); + + test('syncIssue does nothing for issues not included in project', async () => { + await issueSync.syncIssue('41'); + expect(mockGithub.setProjectItem).not.toHaveBeenCalled(); + }); +}); diff --git a/tools/@aws-cdk/project-sync/test/snapshots/generate.ts b/tools/@aws-cdk/project-sync/test/snapshots/generate.ts new file mode 100644 index 0000000000000..1bb56590e63fd --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/generate.ts @@ -0,0 +1,11 @@ +import { Github } from '../../lib/github.js'; +import { PROJECT_NUMBER } from '../../lib/config.js'; +import * as fs from 'node:fs/promises'; +import { join } from 'node:path'; + +const gh = Github.default(); + +(async () => { + await fs.writeFile(join(__dirname, 'get-project-info.json'), JSON.stringify(await gh.getProjectInfo(PROJECT_NUMBER))); + for (const issue of ['15891', '41', '33208', '30793']) {await fs.writeFile(join(__dirname, 'get-issue', `${issue}.json`), JSON.stringify(await gh.getIssue(issue)));} +})().catch(console.error); diff --git a/tools/@aws-cdk/project-sync/test/snapshots/get-issue/15891.json b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/15891.json new file mode 100644 index 0000000000000..02fbc9740754f --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/15891.json @@ -0,0 +1 @@ +{"data":{"repository":{"issue":{"createdAt":"2021-08-04T15:40:27Z","timelineItems":{"nodes":[{"createdAt":"2021-08-30T19:40:23Z","author":{"login":"peterwoodworth"}},{},{},{"createdAt":"2021-08-31T11:35:11Z","author":{"login":"naseemkullah"}},{},{},{"createdAt":"2021-08-31T11:36:30Z","actor":{"login":"github-actions"}},{"createdAt":"2021-08-31T11:36:30Z","actor":{"login":"github-actions"}},{"createdAt":"2021-08-31T18:07:45Z","actor":{"login":"peterwoodworth"}},{"createdAt":"2021-08-31T18:07:48Z","actor":{"login":"peterwoodworth"}},{"createdAt":"2021-09-03T08:45:59Z","actor":{"login":"otaviomacedo"}},{"createdAt":"2021-09-03T09:29:31Z","author":{"login":"otaviomacedo"}},{"createdAt":"2021-09-03T09:29:40Z","actor":{"login":"otaviomacedo"}},{"createdAt":"2021-09-03T13:45:36Z","author":{"login":"naseemkullah"}},{"createdAt":"2021-09-08T01:05:55Z","author":{"login":"quixoticmonk"}},{"createdAt":"2021-09-08T13:15:56Z","author":{"login":"quixoticmonk"}},{"createdAt":"2021-09-11T01:08:59Z","author":{"login":"naseemkullah"}},{"createdAt":"2021-09-16T13:07:49Z","author":{"login":"sblackstone"}},{"createdAt":"2021-09-16T16:59:40Z","actor":{"login":"github-actions"}},{"createdAt":"2021-09-16T16:59:40Z","actor":{"login":"github-actions"}},{"createdAt":"2021-09-16T16:59:40Z","actor":{"login":"github-actions"}},{"createdAt":"2021-09-16T17:49:49Z","author":{"login":"naseemkullah"}},{},{"createdAt":"2021-09-24T08:53:07Z","author":{"login":"otaviomacedo"}},{"createdAt":"2021-09-27T10:53:31Z","actor":{"login":"njlynch"}},{"createdAt":"2021-09-29T14:48:07Z","author":{"login":"jgoux"}},{"createdAt":"2021-10-20T21:41:51Z","author":{"login":"iamjaekim"}},{"createdAt":"2021-11-11T16:47:48Z","author":{"login":"otaviomacedo"}},{"createdAt":"2021-11-11T16:47:48Z","actor":{"login":"otaviomacedo"}},{"createdAt":"2021-11-11T16:48:15Z","author":{"login":"github-actions"}},{"createdAt":"2022-04-12T12:42:07Z","author":{"login":"hugomallet"}},{"createdAt":"2022-05-11T06:12:41Z","author":{"login":"adeelamin15"}},{"createdAt":"2022-05-12T15:55:51Z","author":{"login":"crazyoptimist"}},{"createdAt":"2022-05-12T21:53:48Z","author":{"login":"hlin-neo4j"}},{"createdAt":"2022-08-24T21:46:56Z","author":{"login":"pdrprz"}},{"createdAt":"2022-08-25T19:48:58Z","author":{"login":"abetterbuilder"}},{"createdAt":"2022-09-02T16:55:26Z","author":{"login":"guptalav"}},{"createdAt":"2022-09-12T13:37:30Z","author":{"login":"ES-Six"}},{"createdAt":"2022-09-20T15:02:26Z","author":{"login":"emmanuelnk"}},{"createdAt":"2022-09-30T14:50:13Z","author":{"login":"benjaminpottier"}},{"createdAt":"2022-10-20T11:40:34Z","author":{"login":"edwardofclt"}},{},{},{"createdAt":"2022-10-20T11:47:07Z","author":{"login":"benjaminpottier"}},{},{},{"createdAt":"2022-10-20T11:55:18Z","author":{"login":"edwardofclt"}},{"createdAt":"2022-12-13T15:52:06Z","author":{"login":"LosD"}},{},{},{"createdAt":"2022-12-21T22:03:30Z","author":{"login":"benjaminpottier"}},{"createdAt":"2023-02-15T23:31:15Z","author":{"login":"msheiny"}},{},{"createdAt":"2023-02-16T00:34:07Z","actor":{"login":"msheiny"}},{"createdAt":"2023-02-28T16:12:52Z","author":{"login":"ES-Six"}},{"createdAt":"2023-03-03T08:15:48Z","author":{"login":"emmamoinat"}},{"createdAt":"2023-03-03T19:17:03Z","actor":{"login":"peterwoodworth"}},{"createdAt":"2023-04-19T21:21:50Z","author":{"login":"nalejandroveron"}},{"createdAt":"2023-04-20T17:29:31Z","author":{"login":"jkbailey"}},{"createdAt":"2023-05-03T09:57:08Z","author":{"login":"calebwilson706"}},{"createdAt":"2023-05-03T10:32:26Z","author":{"login":"miekassu"}},{"createdAt":"2023-05-09T17:07:52Z","actor":{"login":"benjaminpottier"}},{"createdAt":"2023-06-06T15:37:28Z","author":{"login":"costleya"}},{"createdAt":"2023-06-06T15:43:57Z","author":{"login":"niallkeys"}},{"createdAt":"2023-06-06T15:53:08Z","author":{"login":"leantorres73"}},{"createdAt":"2023-06-09T16:23:29Z","author":{"login":"xli2227"}},{"createdAt":"2023-10-23T10:28:23Z","author":{"login":"JonWallsten"}},{"createdAt":"2023-10-23T10:40:13Z","author":{"login":"hugomallet"}},{},{"createdAt":"2023-11-13T15:26:08Z","author":{"login":"nbeag"}},{"createdAt":"2023-11-29T03:54:45Z","author":{"login":"abury"}},{"createdAt":"2023-12-05T01:55:17Z","author":{"login":"mattiLeBlanc"}},{"createdAt":"2023-12-05T10:57:52Z","author":{"login":"MrDark"}},{"createdAt":"2023-12-11T22:13:21Z","author":{"login":"alechewitt"}},{"createdAt":"2024-02-14T19:23:57Z","author":{"login":"richard-collette-precisely"}},{"createdAt":"2024-02-15T06:31:49Z","author":{"login":"abury"}},{"createdAt":"2024-02-27T18:00:37Z","author":{"login":"alexandr2110pro"}},{"createdAt":"2024-02-27T22:45:56Z","author":{"login":"edwardofclt"}},{"createdAt":"2024-02-28T08:04:34Z","author":{"login":"alexandr2110pro"}},{"createdAt":"2024-02-28T10:46:44Z","author":{"login":"edwardofclt"}},{"createdAt":"2024-02-28T20:51:29Z","author":{"login":"jkbailey"}},{"createdAt":"2024-02-28T21:24:13Z","author":{"login":"LosD"}},{"createdAt":"2024-02-28T23:04:07Z","author":{"login":"sblackstone"}},{"createdAt":"2024-06-05T04:26:22Z","author":{"login":"pardeepdhingra"}},{},{},{},{"createdAt":"2024-08-16T12:58:50Z","author":{"login":"ashellunts"}},{"createdAt":"2024-08-17T00:13:54Z","author":{"login":"sblackstone"}},{"createdAt":"2025-05-01T13:01:50Z","author":{"login":"prazian"}},{"createdAt":"2025-05-01T13:49:54Z","author":{"login":"dylan-westbury"}},{"createdAt":"2025-05-01T13:50:03Z","author":{"login":"benhutchins"}},{},{},{"createdAt":"2025-05-01T13:54:36Z","author":{"login":"hassanazharkhan"}},{"createdAt":"2025-05-01T14:18:48Z","author":{"login":"hassanazharkhan"}},{"createdAt":"2025-05-01T15:49:47Z","author":{"login":"chase-robbins"}},{"createdAt":"2025-05-01T22:14:06Z","author":{"login":"SimonCMoore"}},{},{"createdAt":"2025-05-02T15:55:16Z","author":{"login":"dgcole"}}]},"reactions":{"nodes":[{"createdAt":"2025-05-01T18:36:05Z"}]},"projectItems":{"nodes":[{"id":"PVTI_lADOACIPmc4AFShhzgCNksA","project":{"number":65}},{"id":"PVTI_lADOACIPmc4A7TlPzgbanR8","project":{"number":302}}]}}}}} \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/test/snapshots/get-issue/30793.json b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/30793.json new file mode 100644 index 0000000000000..0effead22001a --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/30793.json @@ -0,0 +1 @@ +{"data":{"repository":{"issue":{"createdAt":"2024-07-09T08:10:25Z","timelineItems":{"nodes":[{"createdAt":"2024-07-09T08:10:25Z","actor":{"login":"greg5123334"}},{"createdAt":"2024-07-09T08:10:26Z","actor":{"login":"greg5123334"}},{"createdAt":"2024-07-09T08:10:38Z","actor":{"login":"github-actions"}},{"createdAt":"2024-07-09T18:00:55Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-09T18:00:58Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-09T18:01:00Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-09T19:33:26Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-09T19:33:29Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:05:00Z","author":{"login":"khushail"}},{},{},{"createdAt":"2024-07-10T01:05:16Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:05:19Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:07:01Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:07:05Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:07:08Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-10T01:07:16Z","actor":{"login":"khushail"}},{"createdAt":"2024-07-15T09:01:50Z","actor":{"login":"github-actions"}},{"createdAt":"2024-07-15T09:51:34Z","actor":{"login":"github-actions"}},{"createdAt":"2024-07-18T22:28:49Z","author":{"login":"jaimm"}},{"createdAt":"2024-07-20T09:56:42Z","actor":{"login":"mellevanderlinde"}},{"createdAt":"2024-08-01T02:21:54Z","actor":{"login":"github-actions"}},{"createdAt":"2024-08-14T20:18:53Z","actor":{"login":"LeeroyHannigan"}},{"createdAt":"2024-09-18T19:37:14Z","author":{"login":"everilae"}},{"createdAt":"2024-09-21T09:06:01Z","actor":{"login":"LeeroyHannigan"}},{"createdAt":"2025-02-03T14:59:05Z","actor":{"login":"xonstone"}},{"createdAt":"2025-02-03T23:14:16Z","author":{"login":"RobbieClarken"}},{},{},{},{"createdAt":"2025-03-04T21:29:35Z","author":{"login":"rizwanqayyumi"}},{},{},{},{},{"createdAt":"2025-03-26T23:22:30Z","author":{"login":"pahud"}},{"createdAt":"2025-03-26T23:22:37Z","actor":{"login":"pahud"}},{"createdAt":"2025-03-26T23:22:42Z","actor":{"login":"pahud"}},{"createdAt":"2025-04-02T09:25:32Z","author":{"login":"TheHolyWaffle"}},{},{},{},{},{},{},{"createdAt":"2025-05-09T22:39:35Z","actor":{"login":"QuantumNeuralCoder"}},{},{}]},"reactions":{"nodes":[{"createdAt":"2025-05-26T15:43:23Z"}]},"projectItems":{"nodes":[{"id":"PVTI_lADOACIPmc4Av_32zgYvp8Y","project":{"number":263}},{"id":"PVTI_lADOACIPmc4A7TlPzgbamKo","project":{"number":302}}]}}}}} \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/test/snapshots/get-issue/33208.json b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/33208.json new file mode 100644 index 0000000000000..64a77e1838375 --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/33208.json @@ -0,0 +1 @@ +{"data":{"repository":{"issue":{"createdAt":"2025-01-28T09:56:52Z","timelineItems":{"nodes":[{"createdAt":"2025-01-28T09:56:53Z","actor":{"login":"aubsamai"}},{"createdAt":"2025-01-28T09:56:53Z","actor":{"login":"aubsamai"}},{"createdAt":"2025-01-28T09:57:05Z","actor":{"login":"github-actions"}},{"createdAt":"2025-01-28T18:07:38Z","author":{"login":"ashishdhingra"}},{},{},{"createdAt":"2025-01-28T18:07:49Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T18:07:49Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T18:07:49Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T18:38:35Z","author":{"login":"aubsamai"}},{},{},{},{},{"createdAt":"2025-01-28T20:05:12Z","actor":{"login":"github-actions"}},{"createdAt":"2025-01-28T22:04:22Z","author":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T22:04:36Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T22:04:36Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-01-28T22:04:36Z","actor":{"login":"ashishdhingra"}},{"createdAt":"2025-02-01T02:23:45Z","actor":{"login":"github-actions"}},{"createdAt":"2025-05-20T14:07:47Z","author":{"login":"kumsmrit"}},{},{},{"createdAt":"2025-05-22T07:56:17Z","actor":{"login":"kumsmrit"}},{"createdAt":"2025-05-26T14:55:04Z","actor":{"login":"kumsmrit"}},{"createdAt":"2025-05-26T16:05:58Z","author":{"login":"github-actions"}},{"createdAt":"2025-05-26T16:05:59Z","actor":{"login":"github-actions"}},{},{"createdAt":"2025-05-31T20:05:40Z","actor":{"login":"github-actions"}},{"createdAt":"2025-05-31T20:21:39Z","actor":{"login":"github-actions"}},{"createdAt":"2025-06-12T16:00:02Z","actor":{"login":"kumsmrit"}},{"createdAt":"2025-06-12T16:06:30Z","author":{"login":"github-actions"}},{"createdAt":"2025-06-12T16:06:30Z","actor":{"login":"github-actions"}}]},"reactions":{"nodes":[]},"projectItems":{"nodes":[{"id":"PVTI_lADOACIPmc4AaumQzgWws_M","project":{"number":179}},{"id":"PVTI_lADOACIPmc4AbZkFzgWyTLQ","project":{"number":189}},{"id":"PVTI_lADOACIPmc4Av_32zgazLYE","project":{"number":263}},{"id":"PVTI_lADOACIPmc4A7TlPzgbamBo","project":{"number":302}}]}}}}} \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/test/snapshots/get-issue/41.json b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/41.json new file mode 100644 index 0000000000000..8ee98b9bdc20b --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/get-issue/41.json @@ -0,0 +1 @@ +{"data":{"repository":{"issue":{"createdAt":"2018-06-05T20:35:30Z","timelineItems":{"nodes":[{"createdAt":"2018-12-17T08:09:29Z","actor":{"login":"eladb"}},{"createdAt":"2018-12-17T08:09:36Z","actor":{"login":"eladb"}},{"createdAt":"2018-12-17T08:09:41Z","actor":{"login":"eladb"}},{"createdAt":"2018-12-17T08:09:41Z","actor":{"login":"eladb"}},{"createdAt":"2019-01-03T23:48:22Z","actor":{"login":"srchase"}},{"createdAt":"2019-03-04T08:12:57Z","actor":{"login":"eladb"}},{"createdAt":"2019-08-12T15:53:17Z","actor":{"login":"fulghum"}},{"createdAt":"2019-10-02T17:51:47Z","author":{"login":"eladb"}},{"createdAt":"2020-02-03T22:56:35Z","actor":{"login":"shivlaks"}},{"createdAt":"2020-08-26T07:08:59Z","actor":{"login":"shivlaks"}},{"createdAt":"2021-01-25T16:13:39Z","actor":{"login":"NGL321"}},{"createdAt":"2021-01-25T16:13:39Z","actor":{"login":"NGL321"}},{"createdAt":"2021-06-17T15:34:14Z","actor":{"login":"ericzbeard"}},{"createdAt":"2022-06-17T16:05:02Z","author":{"login":"github-actions"}},{"createdAt":"2022-06-17T16:05:03Z","actor":{"login":"github-actions"}},{"createdAt":"2022-06-22T16:05:26Z","actor":{"login":"github-actions"}},{"createdAt":"2022-06-22T16:05:26Z","actor":{"login":"github-actions"}},{"createdAt":"2022-06-22T16:05:27Z","actor":{"login":"github-actions"}},{"createdAt":"2024-06-24T14:05:46Z","actor":{"login":"waltervargas"}}]},"reactions":{"nodes":[]},"projectItems":{"nodes":[]}}}}} \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/test/snapshots/get-project-info.json b/tools/@aws-cdk/project-sync/test/snapshots/get-project-info.json new file mode 100644 index 0000000000000..5b17f094b0aa0 --- /dev/null +++ b/tools/@aws-cdk/project-sync/test/snapshots/get-project-info.json @@ -0,0 +1 @@ +{"data":{"repository":{"projectV2":{"id":"PVT_kwDOACIPmc4A7TlP","fields":{"nodes":[{"id":"PVTF_lADOACIPmc4A7TlPzgvpNb8","name":"Title"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcA","name":"Assignees"},{},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcI","name":"Labels"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcM","name":"Linked pull requests"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcQ","name":"Milestone"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcU","name":"Repository"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcc","name":"Reviewers"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNcg","name":"Parent issue"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNck","name":"Sub-issues progress"},{},{},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNfE","name":"Estimate"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNfI","name":"Start date"},{"id":"PVTF_lADOACIPmc4A7TlPzgvpNfM","name":"End date"},{"id":"PVTF_lADOACIPmc4A7TlPzgvqxXA","name":"Create date"},{"id":"PVTF_lADOACIPmc4A7TlPzgv350s","name":"Update date"}]}}}}} \ No newline at end of file diff --git a/tools/@aws-cdk/project-sync/tsconfig.json b/tools/@aws-cdk/project-sync/tsconfig.json new file mode 100644 index 0000000000000..fadf42d2d68cd --- /dev/null +++ b/tools/@aws-cdk/project-sync/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["es2020", "dom"], + "strict": true, + "alwaysStrict": true, + "declaration": true, + "inlineSourceMap": true, + "inlineSources": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true, + "composite": true, + "incremental": true, + "moduleResolution": "node", + "types": ["node"] + }, + "include": ["**/*.ts"], + "exclude": ["**/*.d.ts"] +}