Skip to content

Commit

Permalink
add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sujjeee committed Oct 2, 2024
1 parent 628eb46 commit 6ad704b
Show file tree
Hide file tree
Showing 19 changed files with 15,702 additions and 11,109 deletions.
3 changes: 3 additions & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.env
67 changes: 67 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "dub-cli",
"version": "0.0.1",
"description": "A CLI for easily shortening URLs.",
"publishConfig": {
"access": "public"
},
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"main": "./dist/index.js",
"bin": {
"dub": "./dist/index.js"
},
"preferGlobal": true,
"author": "Steven Tey <[email protected]>",
"homepage": "https://dub.co",
"repository": {
"type": "git",
"url": "git+https://github.com/steven-tey/dub.git"
},
"bugs": {
"url": "https://github.com/steven-tey/dub/issues"
},
"keywords": [
"dub",
"dub.co",
"dub cli",
"cli"
],
"license": "MIT",
"files": [
"dist"
],
"scripts": {
"dev": "tsup --watch",
"build": "tsup",
"typecheck": "tsc --noEmit",
"clean": "rimraf dist",
"start": "node dist/index.js ",
"pub:release": "pnpm build && pnpm publish --access public"
},
"dependencies": {
"chalk": "^5.3.0",
"commander": "^11.1.0",
"configstore": "^6.0.0",
"fs-extra": "^11.2.0",
"json-colorizer": "^2.2.2",
"nanoid": "^5.0.7",
"node-fetch": "^3.3.2",
"ora": "^7.0.1",
"package-json": "^8.1.1",
"prompts": "^2.4.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/configstore": "^6.0.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "18.11.9",
"@types/prompts": "^2.4.9",
"rimraf": "^5.0.10",
"ts-node": "^10.9.2",
"tsup": "^6.7.0",
"type-fest": "^4.26.1",
"typescript": "^5.6.2"
}
}
34 changes: 34 additions & 0 deletions packages/cli/src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { getConfig } from "@/utils/get-config"
import { handleError } from "@/utils/handle-error"
import { logger } from "@/utils/logger"
import { Command } from "commander"
import colorizeJson from "json-colorizer"
import ora from "ora"

export const config = new Command()
.name("config")
.description("see your configured workspace credentails")
.action(async () => {
const spinner = ora("Getting config file").start()

try {
const configInfo = await getConfig()

spinner.succeed("Configuration file successfully retrieved")

logger.info("")
console.log(
colorizeJson(JSON.stringify(configInfo, null, 2), {
colors: {
STRING_KEY: "white",
STRING_LITERAL: "#65B741",
NUMBER_LITERAL: "#7E30E1"
}
})
)
logger.info("")
} catch (error) {
spinner.stop()
handleError(error)
}
})
Loading

0 comments on commit 6ad704b

Please sign in to comment.