Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(actions): Add Discord message release hook (#295)

authored by

Phil Pluckthun and committed by
GitHub
cf539ba4 875b7527

+273 -8
+85
.github/actions/discord-message/action.mjs
··· 1 + import * as core from '@actions/core'; 2 + import * as github from '@actions/github'; 3 + 4 + const GITHUB_TOKEN = process.env.GITHUB_TOKEN; 5 + const WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL; 6 + 7 + const octokit = github.getOctokit(GITHUB_TOKEN); 8 + 9 + const formatBody = (input) => { 10 + const titleRe = /(?:^|\n)#+[^\n]+/g; 11 + const updatedDepsRe = /\n-\s*Updated dependencies[\s\S]+\n(\n\s+-[\s\S]+)*/gi; 12 + const markdownLinkRe = /\[([^\]]+)\]\(([^\)]+)\)/g; 13 + const creditRe = new RegExp(`Submitted by (?:undefined|${markdownLinkRe.source})`, 'ig'); 14 + const repeatedNewlineRe = /(\n[ ]*)+/g; 15 + return input 16 + .replace(titleRe, '') 17 + .replace(updatedDepsRe, '') 18 + .replace(creditRe, (_match, text, url) => { 19 + if (!text || /@kitten|@JoviDeCroock/i.test(text)) return ''; 20 + return `Submitted by [${text}](${url})`; 21 + }) 22 + .replace(markdownLinkRe, (_match, text, url) => { 23 + return `[${text}](<${url}>)`; 24 + }) 25 + .replace(repeatedNewlineRe, '\n') 26 + .trim(); 27 + }; 28 + 29 + async function getReleaseBody(name, version) { 30 + const tag = `${name}@${version}`; 31 + const result = await octokit.rest.repos.getReleaseByTag({ 32 + owner: 'urql-graphql', 33 + repo: 'urql', 34 + tag, 35 + }); 36 + 37 + const release = result.status === 200 ? result.data : undefined; 38 + if (!release || !release.body) return; 39 + 40 + const title = `:package: [${tag}](<${release.html_url}>)`; 41 + const body = formatBody(release.body); 42 + if (!body) return; 43 + 44 + return `${title}\n${body}`; 45 + } 46 + 47 + async function main() { 48 + const inputPackages = core.getInput('publishedPackages'); 49 + let packages; 50 + 51 + try { 52 + packages = JSON.parse(inputPackages); 53 + } catch (e) { 54 + console.error('invalid JSON in publishedPackages input.'); 55 + return; 56 + } 57 + 58 + // Get releases 59 + const releasePromises = packages.map((entry) => { 60 + return getReleaseBody(entry.name, entry.version); 61 + }); 62 + 63 + const content = (await Promise.allSettled(releasePromises)) 64 + .map((x) => x.status === 'fulfilled' && x.value) 65 + .filter(Boolean) 66 + .join('\n\n'); 67 + 68 + // Send message through a discord webhook or bot 69 + const response = fetch(WEBHOOK_URL, { 70 + method: 'POST', 71 + headers: { 72 + 'Content-Type': 'application/json', 73 + }, 74 + body: JSON.stringify({ content }), 75 + }); 76 + 77 + if (!response.ok) { 78 + console.log('Something went wrong while sending the discord webhook.'); 79 + return; 80 + } 81 + 82 + return response; 83 + } 84 + 85 + main().then().catch(console.error);
+9
.github/actions/discord-message/action.yml
··· 1 + name: 'Send a discord message' 2 + description: 'Send a discord message as a result of a gql.tada publish.' 3 + inputs: 4 + publishedPackages: 5 + description: > 6 + A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]` 7 + runs: 8 + using: 'node20' 9 + main: 'action.mjs'
+1 -1
.github/workflows/ci.yaml
··· 20 20 - name: Setup Node 21 21 uses: actions/setup-node@v4 22 22 with: 23 - node-version: '18' 23 + node-version: 20 24 24 25 25 - name: Setup pnpm 26 26 uses: pnpm/action-setup@v3
+12 -1
.github/workflows/release.yaml
··· 25 25 - name: Setup Node 26 26 uses: actions/setup-node@v4 27 27 with: 28 - node-version: 18 28 + node-version: 20 29 29 30 30 - name: Setup pnpm 31 31 uses: pnpm/action-setup@v3 ··· 57 57 env: 58 58 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 59 59 NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 60 + 61 + - name: Notify discord 62 + id: discord-msg 63 + if: steps.changesets.outputs.published == 'true' 64 + uses: ./.github/actions/discord-message 65 + with: 66 + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} 67 + env: 68 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 69 + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 70 + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
+2
package.json
··· 25 25 } 26 26 }, 27 27 "devDependencies": { 28 + "@actions/core": "^1.10.0", 29 + "@actions/github": "^5.1.1", 28 30 "@babel/plugin-transform-block-scoping": "^7.23.4", 29 31 "@babel/plugin-transform-typescript": "^7.23.6", 30 32 "@changesets/cli": "^2.26.2",
+164 -6
pnpm-lock.yaml
··· 18 18 19 19 .: 20 20 devDependencies: 21 + '@actions/core': 22 + specifier: ^1.10.0 23 + version: 1.10.1 24 + '@actions/github': 25 + specifier: ^5.1.1 26 + version: 5.1.1 21 27 '@babel/plugin-transform-block-scoping': 22 28 specifier: ^7.23.4 23 29 version: 7.23.4(@babel/core@7.23.7) ··· 301 307 dependencies: 302 308 graphql: 16.8.1 303 309 310 + /@actions/core@1.10.1: 311 + resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==} 312 + dependencies: 313 + '@actions/http-client': 2.2.1 314 + uuid: 8.3.2 315 + dev: true 316 + 317 + /@actions/github@5.1.1: 318 + resolution: {integrity: sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==} 319 + dependencies: 320 + '@actions/http-client': 2.2.1 321 + '@octokit/core': 3.6.0 322 + '@octokit/plugin-paginate-rest': 2.21.3(@octokit/core@3.6.0) 323 + '@octokit/plugin-rest-endpoint-methods': 5.16.2(@octokit/core@3.6.0) 324 + transitivePeerDependencies: 325 + - encoding 326 + dev: true 327 + 328 + /@actions/http-client@2.2.1: 329 + resolution: {integrity: sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==} 330 + dependencies: 331 + tunnel: 0.0.6 332 + undici: 5.28.4 333 + dev: true 334 + 304 335 /@ampproject/remapping@2.2.1: 305 336 resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} 306 337 engines: {node: '>=6.0.0'} ··· 1323 1354 dev: true 1324 1355 optional: true 1325 1356 1357 + /@fastify/busboy@2.1.1: 1358 + resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} 1359 + engines: {node: '>=14'} 1360 + dev: true 1361 + 1326 1362 /@gql.tada/cli-utils@0.3.0: 1327 1363 resolution: {integrity: sha512-kDebLVuM5r3/bI1MmlhHr9VKHxXeq8Gxy1wHVTPva4R5ObfbhzxnHsTCvR6MUp8ziy9Pg9MESb8S1YZW8ohM3A==} 1328 1364 dependencies: ··· 1341 1377 resolution: {integrity: sha512-8I4Z1zxYYGK66FWdB3yIZBn3cITLPnciEgjChp3K2+Ha1e/AEBGtZv9AUlodraO/RZafDMkpFhoi+tMpluBjeg==} 1342 1378 peerDependencies: 1343 1379 graphql: ^16.8.1 1344 - typescript: ^5.0.0 1380 + typescript: ^5.3.3 1345 1381 dependencies: 1346 1382 '@0no-co/graphql.web': 1.0.6(graphql@16.8.1) 1347 1383 graphql: 16.8.1 ··· 2038 2074 fastq: 1.13.0 2039 2075 dev: true 2040 2076 2077 + /@octokit/auth-token@2.5.0: 2078 + resolution: {integrity: sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==} 2079 + dependencies: 2080 + '@octokit/types': 6.41.0 2081 + dev: true 2082 + 2083 + /@octokit/core@3.6.0: 2084 + resolution: {integrity: sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==} 2085 + dependencies: 2086 + '@octokit/auth-token': 2.5.0 2087 + '@octokit/graphql': 4.8.0 2088 + '@octokit/request': 5.6.3 2089 + '@octokit/request-error': 2.1.0 2090 + '@octokit/types': 6.41.0 2091 + before-after-hook: 2.2.3 2092 + universal-user-agent: 6.0.1 2093 + transitivePeerDependencies: 2094 + - encoding 2095 + dev: true 2096 + 2097 + /@octokit/endpoint@6.0.12: 2098 + resolution: {integrity: sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==} 2099 + dependencies: 2100 + '@octokit/types': 6.41.0 2101 + is-plain-object: 5.0.0 2102 + universal-user-agent: 6.0.1 2103 + dev: true 2104 + 2105 + /@octokit/graphql@4.8.0: 2106 + resolution: {integrity: sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==} 2107 + dependencies: 2108 + '@octokit/request': 5.6.3 2109 + '@octokit/types': 6.41.0 2110 + universal-user-agent: 6.0.1 2111 + transitivePeerDependencies: 2112 + - encoding 2113 + dev: true 2114 + 2115 + /@octokit/openapi-types@12.11.0: 2116 + resolution: {integrity: sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==} 2117 + dev: true 2118 + 2119 + /@octokit/plugin-paginate-rest@2.21.3(@octokit/core@3.6.0): 2120 + resolution: {integrity: sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==} 2121 + peerDependencies: 2122 + '@octokit/core': '>=2' 2123 + dependencies: 2124 + '@octokit/core': 3.6.0 2125 + '@octokit/types': 6.41.0 2126 + dev: true 2127 + 2128 + /@octokit/plugin-rest-endpoint-methods@5.16.2(@octokit/core@3.6.0): 2129 + resolution: {integrity: sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==} 2130 + peerDependencies: 2131 + '@octokit/core': '>=3' 2132 + dependencies: 2133 + '@octokit/core': 3.6.0 2134 + '@octokit/types': 6.41.0 2135 + deprecation: 2.3.1 2136 + dev: true 2137 + 2138 + /@octokit/request-error@2.1.0: 2139 + resolution: {integrity: sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==} 2140 + dependencies: 2141 + '@octokit/types': 6.41.0 2142 + deprecation: 2.3.1 2143 + once: 1.4.0 2144 + dev: true 2145 + 2146 + /@octokit/request@5.6.3: 2147 + resolution: {integrity: sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==} 2148 + dependencies: 2149 + '@octokit/endpoint': 6.0.12 2150 + '@octokit/request-error': 2.1.0 2151 + '@octokit/types': 6.41.0 2152 + is-plain-object: 5.0.0 2153 + node-fetch: 2.6.7 2154 + universal-user-agent: 6.0.1 2155 + transitivePeerDependencies: 2156 + - encoding 2157 + dev: true 2158 + 2159 + /@octokit/types@6.41.0: 2160 + resolution: {integrity: sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==} 2161 + dependencies: 2162 + '@octokit/openapi-types': 12.11.0 2163 + dev: true 2164 + 2041 2165 /@peculiar/asn1-schema@2.3.8: 2042 2166 resolution: {integrity: sha512-ULB1XqHKx1WBU/tTFIA+uARuRoBVZ4pNdOA878RDrRbBfBGcSzi5HBkdScC6ZbHn8z7L8gmKCgPC1LHRrP46tA==} 2043 2167 dependencies: ··· 2144 2268 peerDependencies: 2145 2269 rollup: ^2.14.0||^3.0.0||^4.0.0 2146 2270 tslib: '*' 2147 - typescript: '>=3.7.0' 2271 + typescript: ^5.3.3 2148 2272 peerDependenciesMeta: 2149 2273 rollup: 2150 2274 optional: true ··· 2691 2815 resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} 2692 2816 dev: true 2693 2817 2818 + /before-after-hook@2.2.3: 2819 + resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} 2820 + dev: true 2821 + 2694 2822 /better-path-resolve@1.0.0: 2695 2823 resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} 2696 2824 engines: {node: '>=4'} ··· 3046 3174 resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} 3047 3175 engines: {node: '>=14'} 3048 3176 peerDependencies: 3049 - typescript: '>=4.9.5' 3177 + typescript: ^5.3.3 3050 3178 peerDependenciesMeta: 3051 3179 typescript: 3052 3180 optional: true ··· 3200 3328 /dependency-graph@0.11.0: 3201 3329 resolution: {integrity: sha512-JeMq7fEshyepOWDfcfHK06N3MhyPhz++vtqWhMT5O9A3K42rdsEDpfdVqjaqaAhsw6a+ZqeDvQVtD0hFHQWrzg==} 3202 3330 engines: {node: '>= 0.6.0'} 3331 + dev: true 3332 + 3333 + /deprecation@2.3.1: 3334 + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} 3203 3335 dev: true 3204 3336 3205 3337 /detect-indent@6.1.0: ··· 4089 4221 engines: {node: '>=0.10.0'} 4090 4222 dev: true 4091 4223 4224 + /is-plain-object@5.0.0: 4225 + resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} 4226 + engines: {node: '>=0.10.0'} 4227 + dev: true 4228 + 4092 4229 /is-reference@1.2.1: 4093 4230 resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} 4094 4231 dependencies: ··· 5164 5301 engines: {node: '>=16'} 5165 5302 peerDependencies: 5166 5303 rollup: ^3.29.4 || ^4 5167 - typescript: ^4.5 || ^5.0 5304 + typescript: ^5.3.3 5168 5305 dependencies: 5169 5306 magic-string: 0.30.5 5170 5307 rollup: 4.9.5 ··· 5664 5801 '@swc/core': '>=1.2.50' 5665 5802 '@swc/wasm': '>=1.2.50' 5666 5803 '@types/node': '*' 5667 - typescript: '>=2.7' 5804 + typescript: ^5.3.3 5668 5805 peerDependenciesMeta: 5669 5806 '@swc/core': 5670 5807 optional: true ··· 5710 5847 yargs: 17.7.1 5711 5848 dev: true 5712 5849 5850 + /tunnel@0.0.6: 5851 + resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} 5852 + engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} 5853 + dev: true 5854 + 5713 5855 /type-detect@4.0.8: 5714 5856 resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} 5715 5857 engines: {node: '>=4'} ··· 5775 5917 engines: {node: '>=0.10.0'} 5776 5918 dev: true 5777 5919 5920 + /undici@5.28.4: 5921 + resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} 5922 + engines: {node: '>=14.0'} 5923 + dependencies: 5924 + '@fastify/busboy': 2.1.1 5925 + dev: true 5926 + 5927 + /universal-user-agent@6.0.1: 5928 + resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==} 5929 + dev: true 5930 + 5778 5931 /universalify@0.1.2: 5779 5932 resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} 5780 5933 engines: {node: '>= 4.0.0'} ··· 5832 5985 5833 5986 /util-deprecate@1.0.2: 5834 5987 resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} 5988 + dev: true 5989 + 5990 + /uuid@8.3.2: 5991 + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} 5992 + hasBin: true 5835 5993 dev: true 5836 5994 5837 5995 /v8-compile-cache-lib@3.0.1: ··· 6206 6364 id: file:packages/graphqlsp 6207 6365 name: '@0no-co/graphqlsp' 6208 6366 peerDependencies: 6209 - typescript: ^5.0.0 6367 + typescript: ^5.3.3 6210 6368 dependencies: 6211 6369 '@gql.tada/internal': 0.1.2(graphql@16.8.1)(typescript@5.3.3) 6212 6370 graphql: 16.8.1