chore: star prompt (#2955)

Shows a prompt to star Medusa after killing the develop server the first time:
![CleanShot 2023-01-06 at 2 30 19](https://user-images.githubusercontent.com/7554214/211022169-8a0d753e-1628-485e-9037-0e817adf5d3f.png)

The prompt will not reappear on subsequent kills.
This commit is contained in:
Sebastian Rindom
2023-01-06 16:12:47 +01:00
committed by GitHub
parent 8ba0addea3
commit a93d5d437c

View File

@@ -1,16 +1,44 @@
import { EOL } from "os"
import boxen from "boxen"
import path from "path"
import { execSync } from "child_process"
import spawn from "cross-spawn"
import chokidar from "chokidar"
import Store from "medusa-telemetry/dist/store"
import Logger from "../loaders/logger"
const defaultConfig = {
padding: 5,
borderColor: `blue`,
borderStyle: `double`,
}
export default async function ({ port, directory }) {
const args = process.argv
args.shift()
args.shift()
args.shift()
process.on("SIGINT", () => {
const configStore = new Store()
const hasPrompted = configStore.getConfig("star.prompted") ?? false
if (!hasPrompted) {
const defaultMessage =
`✨ Thanks for using Medusa. ✨${EOL}${EOL}` +
`If you liked it, please consider starring us on GitHub${EOL}` +
`https://medusajs.com/star${EOL}` +
`${EOL}` +
`Note: you will not see this message again.`
console.log()
console.log(boxen(defaultMessage, defaultConfig))
configStore.setConfig("star.prompted", true)
}
process.exit(0)
})
const babelPath = path.join(directory, "node_modules", ".bin", "babel")
execSync(`"${babelPath}" src -d dist`, {