-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd.ts
51 lines (45 loc) · 1.09 KB
/
cmd.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { $ } from "bun"
import { LaAccount } from "@/web/src/schema"
import { startWorker } from "jazz-nodejs"
// TODO: make more robust
const seedAccounts = JSON.parse(process.env.SEED_ACCOUNTS!)
async function main() {
const args = Bun.argv
const command = args[2]
try {
switch (command) {
case "setup":
await setup()
break
case "jazz-state":
await getJazzState()
break
}
} catch (err) {
console.error("Error:", err)
}
}
// TODO: make `bun setup` setup everything (jazz, seed, auth etc.)
// so readme is just `bun i`, `bun setup`, `bun dev` (and open localhost and start developing)
async function setup() {
await $`git clone https://github.com/learn-anything/seed cli/seed`
}
// gets state for Jazz user
async function getJazzState() {
const me = await (
await startWorker({
accountID: seedAccounts.nikiv.accountID,
accountSecret: seedAccounts.nikiv.accountSecret,
accountSchema: LaAccount,
})
).worker.ensureLoaded({
root: {
personalLinks: [{}],
pages: [{}],
todos: [{}],
},
})
if (!me) return
console.log(me.root.toJSON())
}
await main()