Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Makisuo committed Jan 18, 2025
1 parent e86627a commit a7f6ccc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/commands/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { customAlphabet } from "nanoid"

import { listen } from "async-listen"
import chalk from "chalk"
import { updateUser } from "rc9"
import { readUser, updateUser } from "rc9"

const FILENAME = ".justd"
const DOMAIN = "https://blocks.getjustd.com"
// const DOMAIN = "https://blocks.getjustd.com"
const DOMAIN = "http://localhost:3000"

class UserCancellationError extends Error {
constructor(message: string) {
Expand All @@ -23,7 +24,17 @@ class UserCancellationError extends Error {

const nanoid = customAlphabet("123456789QAZWSXEDCRFVTGBYHNUJMIKOLP", 8)

export const addBlock = async () => {}
export const addBlock = async () => {
const config = readUser(FILENAME)

const res = await fetch(`${DOMAIN}/api/blocks/wow`, {
headers: {
"x-api-key": config.key,
},
})

console.log(await res.text())
}

export const loginBlock = async () => {
const server = http.createServer()
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { program } from "commander"
import open from "open"
import packageJson from "../package.json"
import { add } from "./commands/add"
import { loginBlock } from "./commands/blocks"
import { addBlock, loginBlock } from "./commands/blocks"
import { setGray } from "./commands/change-gray"
import { diff } from "./commands/diff"
import { help } from "./commands/help"
Expand Down Expand Up @@ -70,6 +70,14 @@ program.command("login").action(async () => {
await loginBlock()
})

program
.command("block [components...]")
.option("--skip <type>", "Skip")
.option("-o, --overwrite", "Override existing components")
.action(async () => {
await addBlock()
})

/**
* This command is used to change the current gray
* You can see the full theme list here: https://getjustd.com/themes
Expand Down

0 comments on commit a7f6ccc

Please sign in to comment.