create-arona-app 0.0.1-dev.ff9c398 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -44
- package/bin/create-arona-app.js +115 -112
- package/package.json +23 -21
- package/templates/alchemy/README.md +17 -0
- package/templates/alchemy/alchemy.run.ts +16 -0
- package/templates/alchemy/package.json +28 -0
- package/templates/alchemy/src/counter.ts +38 -0
- package/templates/alchemy/src/register.ts +26 -0
- package/templates/alchemy/src/resources.ts +8 -0
- package/templates/alchemy/src/worker.ts +29 -0
- package/templates/alchemy/tsconfig.json +22 -0
- package/templates/counter/.env.example +3 -0
- package/templates/counter/README.md +17 -0
- package/templates/counter/package.json +21 -0
- package/templates/counter/src/index.ts +72 -0
- package/templates/counter/tsconfig.json +22 -0
- package/templates/counter/vite.config.ts +6 -0
- package/templates/default/.env.example +3 -0
- package/templates/default/package.json +14 -12
- package/templates/default/src/counter.ts +65 -0
- package/templates/default/src/index.ts +36 -14
- package/templates/default/tsconfig.json +20 -26
- package/templates/default/vite.config.ts +7 -0
- package/templates/rick-and-morty/.env.example +4 -0
- package/templates/rick-and-morty/package.json +15 -12
- package/templates/rick-and-morty/src/commands/search.ts +15 -0
- package/templates/rick-and-morty/src/components/search/character.ts +57 -0
- package/templates/rick-and-morty/src/components/search/index.ts +99 -0
- package/templates/rick-and-morty/src/components/search/pagination.ts +49 -0
- package/templates/rick-and-morty/src/components/search/search-form.ts +60 -0
- package/templates/rick-and-morty/src/components/search/status.ts +22 -0
- package/templates/rick-and-morty/src/index.ts +40 -14
- package/templates/rick-and-morty/src/queries/characters.ts +89 -0
- package/templates/rick-and-morty/tsconfig.json +20 -26
- package/templates/rick-and-morty/vite.config.ts +7 -0
- package/templates/serverless/README.md +17 -0
- package/templates/serverless/package.json +22 -0
- package/templates/serverless/src/counter.ts +39 -0
- package/templates/serverless/src/handler.ts +38 -0
- package/templates/serverless/src/index.ts +78 -0
- package/templates/serverless/src/register.ts +21 -0
- package/templates/serverless/tsconfig.json +22 -0
- package/templates/simple/.env.example +3 -0
- package/templates/simple/package.json +13 -12
- package/templates/simple/src/app.ts +147 -0
- package/templates/simple/src/index.ts +57 -0
- package/templates/simple/tsconfig.json +20 -26
- package/templates/simple/vite.config.ts +6 -0
- package/templates/slack/.env.example +3 -0
- package/templates/slack/README.md +17 -0
- package/templates/slack/package.json +22 -0
- package/templates/slack/src/app.ts +45 -0
- package/templates/slack/src/index.ts +43 -0
- package/templates/slack/tsconfig.json +22 -0
- package/templates/slack/vite.config.ts +6 -0
- package/templates/default/src/commands/counter/counter.tsx +0 -53
- package/templates/default/src/commands/counter/index.ts +0 -7
- package/templates/rick-and-morty/src/commands/rick-and-morty/app.tsx +0 -28
- package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-display.tsx +0 -40
- package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-search-modal.tsx +0 -34
- package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-search.tsx +0 -29
- package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-select.tsx +0 -36
- package/templates/rick-and-morty/src/commands/rick-and-morty/components/navigation.tsx +0 -58
- package/templates/rick-and-morty/src/commands/rick-and-morty/hooks/character-search-provider.tsx +0 -90
- package/templates/rick-and-morty/src/commands/rick-and-morty/hooks/useCharacters.ts +0 -38
- package/templates/rick-and-morty/src/commands/rick-and-morty/index.ts +0 -21
- package/templates/rick-and-morty/src/commands/rick-and-morty/types.ts +0 -24
- package/templates/simple/src/app.tsx +0 -38
- package/templates/simple/src/index.tsx +0 -33
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query"
|
|
2
|
-
import type { Character, PageMetadata } from "../types"
|
|
3
|
-
|
|
4
|
-
type APIResponse = {
|
|
5
|
-
info: PageMetadata
|
|
6
|
-
results: Character[]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const useCharacters = (search: string, page: number) => {
|
|
10
|
-
const { data, ...query } = useQuery({
|
|
11
|
-
queryKey: ["character", search, page],
|
|
12
|
-
queryFn: async () => {
|
|
13
|
-
const response = await fetch(
|
|
14
|
-
`https://rickandmortyapi.com/api/character/?name=${search}&page=${page}`,
|
|
15
|
-
)
|
|
16
|
-
const data = (await response.json()) as APIResponse
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
characters: data.results,
|
|
20
|
-
pageMetadata: data.info,
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
if (!data) {
|
|
26
|
-
return {
|
|
27
|
-
characters: [] as Character[],
|
|
28
|
-
pageMetadata: null,
|
|
29
|
-
isLoading: query.isLoading,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
characters: data.characters ?? [],
|
|
35
|
-
pageMetadata: data.pageMetadata,
|
|
36
|
-
isLoading: query.isLoading,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { App } from "./app"
|
|
2
|
-
import { QueryClient } from "@tanstack/react-query"
|
|
3
|
-
import { createSlashCommand } from "@arona/discord"
|
|
4
|
-
|
|
5
|
-
export const rickAndMortySearch = createSlashCommand("search", {
|
|
6
|
-
command: (command) =>
|
|
7
|
-
command
|
|
8
|
-
.setDescription("Search Rick and Morty API")
|
|
9
|
-
.addTypedStringOption((option) =>
|
|
10
|
-
option
|
|
11
|
-
.setName("query")
|
|
12
|
-
.setDescription("Search query")
|
|
13
|
-
.setRequired(false),
|
|
14
|
-
),
|
|
15
|
-
loader: () => {
|
|
16
|
-
return {
|
|
17
|
-
queryClient: new QueryClient(),
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
component: App,
|
|
21
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type PageMetadata = {
|
|
2
|
-
count: number
|
|
3
|
-
pages: number
|
|
4
|
-
next: string | null
|
|
5
|
-
prev: string | null
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type CharacterStatus = "Alive" | "Dead" | "unknown"
|
|
9
|
-
|
|
10
|
-
export type Character = {
|
|
11
|
-
id: number
|
|
12
|
-
name: string
|
|
13
|
-
status: CharacterStatus
|
|
14
|
-
species: string
|
|
15
|
-
type: string
|
|
16
|
-
gender: string
|
|
17
|
-
origin: {
|
|
18
|
-
name: string
|
|
19
|
-
}
|
|
20
|
-
location: {
|
|
21
|
-
name: string
|
|
22
|
-
}
|
|
23
|
-
image: string
|
|
24
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useModal, Text, ActionRow, Button, Modal, TextInput, Container, Separator, Select, Option, Section } from '@arona/discord'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
import { Message } from 'discord.js'
|
|
4
|
-
|
|
5
|
-
type AppProps = {
|
|
6
|
-
message: Message
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const App = ({message}: AppProps) => {
|
|
10
|
-
const [count, setCount] = useState(0)
|
|
11
|
-
const {openModal} = useModal()
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<Text>-# Original Message: `{message.content}`</Text>
|
|
16
|
-
<Container accentColor="Red">
|
|
17
|
-
<Section accessory={
|
|
18
|
-
<Button onClick={() => setCount(count + 1)}>Add One</Button>
|
|
19
|
-
}>
|
|
20
|
-
<Text># Count `{count}`</Text>
|
|
21
|
-
</Section>
|
|
22
|
-
</Container>
|
|
23
|
-
<Select onChange={(value) => console.log(value)} maxValues={2}>
|
|
24
|
-
<Option value='1'>1</Option>
|
|
25
|
-
<Option value='2'>2</Option>
|
|
26
|
-
<Option value='3' selected>3</Option>
|
|
27
|
-
</Select>
|
|
28
|
-
<Button onClick={openModal(() => (
|
|
29
|
-
<Modal title="test">
|
|
30
|
-
<TextInput label="test" name="test" onChange={(value) => console.log(value)} />
|
|
31
|
-
</Modal>
|
|
32
|
-
))}>Open Modal</Button>
|
|
33
|
-
<Separator/>
|
|
34
|
-
<Text>-# Updated At `{new Date().toISOString()}`</Text>
|
|
35
|
-
</>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AronaDiscordClient, render, renderMessage, Text } from "@arona/discord"
|
|
2
|
-
import { Events, GatewayIntentBits } from "discord.js"
|
|
3
|
-
import { App } from './app'
|
|
4
|
-
|
|
5
|
-
const client = new AronaDiscordClient({
|
|
6
|
-
token: process.env.DISCORD_APP_TOKEN!,
|
|
7
|
-
clientId: process.env.DISCORD_APP_ID!,
|
|
8
|
-
devGuildId: process.env.DISCORD_DEV_GUILD_ID,
|
|
9
|
-
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
client.once(Events.ClientReady, () => {
|
|
13
|
-
console.log(`🚀 Logged in as ${client.user?.tag}`)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
client.on(Events.MessageCreate, async (message) => {
|
|
17
|
-
if (message.author.bot) return
|
|
18
|
-
|
|
19
|
-
const testMessage = await renderMessage(
|
|
20
|
-
message,
|
|
21
|
-
() => <App message={message} />,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!testMessage) return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
await renderMessage(testMessage, () => {
|
|
29
|
-
return <Text>test</Text>
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
await client.login()
|