Last active
December 14, 2019 23:05
-
-
Save stevenvachon/a094e9da3e9bfc8d0352a9d5e7b07f10 to your computer and use it in GitHub Desktop.
grafana yarnlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const yarnlink = useSpinner<void>('Linking local toolkit', async () => { | |
const existingDeps: string[] = ['@grafana/eslint-config', '@grafana/toolkit', '@grafana/tsconfig']; | |
// Remove published dependencies | |
// @todo https://github.com/es-shims/Promise.allSettled/issues/5 | |
await allSettled.call(Promise, existingDeps.map((async dep => { | |
try { | |
await execa('yarn', ['remove', dep]); | |
} catch ({ message }) { | |
console.log('\n', message, '\n'); | |
} | |
}))); | |
// Link to local -- must have been manually linked (see README) | |
await execa('yarn', ['link', ...existingDeps]); | |
const newDeps: string[] = existingDeps | |
.map(dep => require(`${dep}/package.json`)) | |
.map(({ dependencies = {} }) => Object.entries(dependencies)) | |
.flat() | |
// @todo dedupe, excluding older versions | |
.map(([key, value]) => `${key}@${value}`); | |
// Add all the nested dependencies | |
await execa('yarn', ['add', ...newDeps]); | |
console.log('Added dependencies required by local @grafana/toolkit. Do not checkin this package.json!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment