From b7234eab5377b44bd7e7f54b54ec10bdd04e2ec8 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Fri, 13 Dec 2024 12:53:16 +0100 Subject: [PATCH] chore: add postinstall message --- bin/index.ts | 28 +++++++++++++++++++++++----- bin/welcome.mjs | 10 ++++++++++ package.json | 4 +++- 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 bin/welcome.mjs diff --git a/bin/index.ts b/bin/index.ts index e49602f..2223ae0 100644 --- a/bin/index.ts +++ b/bin/index.ts @@ -4,6 +4,8 @@ import openBrowser from 'open' import pc from 'picocolors' import mri from 'mri' +const { white, black } = pc + import { vercelUrl, getSlugAndSection, @@ -16,6 +18,22 @@ async function main () { const { org, project, section } = await getSlugAndSection({ args }) switch (section) { + case 'help': { + console.log( + [ + '', + ' Usage:', + ` ${white('vc open')} [${white('current')}|${white('latest')}] [${white('--visit')}]`, + '', + ' Jump to any section:', + ` ${white('vc open')} [${white('current')}|${white('latest')}] <${white('logs')}|${white('settings')}|${white('etc')}> [${white('--query-parameter')}]` + ] + .map(line => black(line)) + .join('\n') + ) + break + } + case 'latest': { const { id, url: deploymentUrl } = await getLatestDeployment() const url = visit ? deploymentUrl : vercelUrl({ org, project, section: id, flags }) @@ -28,17 +46,17 @@ async function main () { } case 'info': { const { id: latestId } = await getLatestDeployment() - const { id: currentId} = await getProductionDeployment() + const { id: currentId } = await getProductionDeployment() console.log( - pc.black( + black( [ '', - `${pc.white('▲ overview')} https://vercel.com/${org}/${project}/`, - `${pc.white( + `${white('▲ overview')} https://vercel.com/${org}/${project}/`, + `${white( '▲ current (production)' )} https://vercel.com/${org}/${project}/${currentId}/`, - `${pc.white( + `${white( '▲ latest (preview)' )} https://vercel.com/${org}/${project}/${latestId}/` ].join('\n') diff --git a/bin/welcome.mjs b/bin/welcome.mjs new file mode 100644 index 0000000..f04d486 --- /dev/null +++ b/bin/welcome.mjs @@ -0,0 +1,10 @@ +import pc from 'picocolors' + +console.log( + [ + pc.black(`✨ ${pc.white('vercel-open')} installed ✨`), + pc.black(`For using it, just type '${pc.white('vc open')}' or '${pc.white('vercel open')}' in your terminal`), + '', + pc.black(`Type '${pc.white('vc open help')}' to learn about the command`) + ].join('\n') +) diff --git a/package.json b/package.json index b2b132a..6bce82b 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,13 @@ "vitest": "latest" }, "files": [ - "bin/index.js" + "bin/index.js", + "bin/welcome.mjs" ], "scripts": { "build": "tsup --format esm bin/index.ts -d bin/", "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", + "postinstall": "node bin/welcome.mjs", "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)", "prepublishOnly": "npm run build", "release": "standard-version -a",