From 068b8ee996db4632dfd5072b9adb0f71ee9c490b Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 8 Mar 2022 10:48:12 -0600 Subject: [PATCH] fix(ci): update notify script (#2730) --- scripts/notify/index.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/notify/index.js b/scripts/notify/index.js index 950fef1deed9..1a2440382154 100755 --- a/scripts/notify/index.js +++ b/scripts/notify/index.js @@ -1,6 +1,3 @@ -import path from 'path'; -import { createRequire } from 'module'; -const require = createRequire(import.meta.url); const baseUrl = new URL('https://github.com/withastro/astro/blob/main/'); const emojis = ['🎉', '🥳', '🚀', '🧑‍🚀', '🎊', '🏆', '✅', '🤩', '🤖', '🙌']; @@ -53,12 +50,31 @@ function singularlize(text) { return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) => `${match}`); } +const packageMap = new Map([ + ['astro', './packages/astro'], + ['@astrojs/parser', './packages/astro-parser'], + ['@astrojs/prism', './packages/astro-prism'], + ['create-astro', './packages/create-astro'], + ['@astrojs/markdown-remark', './packages/markdown/remark'], + ['@astrojs/renderer-lit', './packages/renderers/renderer-lit'], + ['@astrojs/renderer-preact', './packages/renderers/renderer-preact'], + ['@astrojs/renderer-react', './packages/renderers/renderer-react'], + ['@astrojs/renderer-solid', './packages/renderers/renderer-solid'], + ['@astrojs/renderer-solid', './packages/renderers/renderer-solid'], + ['@astrojs/renderer-svelte', './packages/renderers/renderer-svelte'], + ['@astrojs/renderer-vue', './packages/renderers/renderer-vue'], + ['@astrojs/webapi', './packages/webapi'], +]) + async function run() { const releases = process.argv.slice(2)[0]; const data = JSON.parse(releases); const packages = await Promise.all( data.map(({ name, version }) => { - const p = path.relative('./', path.dirname(require.resolve(name))).replace(path.sep, '/'); + const p = packageMap.get(name); + if (!p) { + throw new Error(`Unable to find entrypoint for "${name}"!`); + } return { name, version, url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString() }; }) );