chore: star prompt (#2955)
Shows a prompt to star Medusa after killing the develop server the first time:  The prompt will not reappear on subsequent kills.
This commit is contained in:
@@ -1,16 +1,44 @@
|
|||||||
|
import { EOL } from "os"
|
||||||
|
import boxen from "boxen"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { execSync } from "child_process"
|
import { execSync } from "child_process"
|
||||||
import spawn from "cross-spawn"
|
import spawn from "cross-spawn"
|
||||||
import chokidar from "chokidar"
|
import chokidar from "chokidar"
|
||||||
|
import Store from "medusa-telemetry/dist/store"
|
||||||
|
|
||||||
import Logger from "../loaders/logger"
|
import Logger from "../loaders/logger"
|
||||||
|
|
||||||
|
const defaultConfig = {
|
||||||
|
padding: 5,
|
||||||
|
borderColor: `blue`,
|
||||||
|
borderStyle: `double`,
|
||||||
|
}
|
||||||
|
|
||||||
export default async function ({ port, directory }) {
|
export default async function ({ port, directory }) {
|
||||||
const args = process.argv
|
const args = process.argv
|
||||||
args.shift()
|
args.shift()
|
||||||
args.shift()
|
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")
|
const babelPath = path.join(directory, "node_modules", ".bin", "babel")
|
||||||
|
|
||||||
execSync(`"${babelPath}" src -d dist`, {
|
execSync(`"${babelPath}" src -d dist`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user