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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -44
  3. package/bin/create-arona-app.js +115 -112
  4. package/package.json +23 -21
  5. package/templates/alchemy/README.md +17 -0
  6. package/templates/alchemy/alchemy.run.ts +16 -0
  7. package/templates/alchemy/package.json +28 -0
  8. package/templates/alchemy/src/counter.ts +38 -0
  9. package/templates/alchemy/src/register.ts +26 -0
  10. package/templates/alchemy/src/resources.ts +8 -0
  11. package/templates/alchemy/src/worker.ts +29 -0
  12. package/templates/alchemy/tsconfig.json +22 -0
  13. package/templates/counter/.env.example +3 -0
  14. package/templates/counter/README.md +17 -0
  15. package/templates/counter/package.json +21 -0
  16. package/templates/counter/src/index.ts +72 -0
  17. package/templates/counter/tsconfig.json +22 -0
  18. package/templates/counter/vite.config.ts +6 -0
  19. package/templates/default/.env.example +3 -0
  20. package/templates/default/package.json +14 -12
  21. package/templates/default/src/counter.ts +65 -0
  22. package/templates/default/src/index.ts +36 -14
  23. package/templates/default/tsconfig.json +20 -26
  24. package/templates/default/vite.config.ts +7 -0
  25. package/templates/rick-and-morty/.env.example +4 -0
  26. package/templates/rick-and-morty/package.json +15 -12
  27. package/templates/rick-and-morty/src/commands/search.ts +15 -0
  28. package/templates/rick-and-morty/src/components/search/character.ts +57 -0
  29. package/templates/rick-and-morty/src/components/search/index.ts +99 -0
  30. package/templates/rick-and-morty/src/components/search/pagination.ts +49 -0
  31. package/templates/rick-and-morty/src/components/search/search-form.ts +60 -0
  32. package/templates/rick-and-morty/src/components/search/status.ts +22 -0
  33. package/templates/rick-and-morty/src/index.ts +40 -14
  34. package/templates/rick-and-morty/src/queries/characters.ts +89 -0
  35. package/templates/rick-and-morty/tsconfig.json +20 -26
  36. package/templates/rick-and-morty/vite.config.ts +7 -0
  37. package/templates/serverless/README.md +17 -0
  38. package/templates/serverless/package.json +22 -0
  39. package/templates/serverless/src/counter.ts +39 -0
  40. package/templates/serverless/src/handler.ts +38 -0
  41. package/templates/serverless/src/index.ts +78 -0
  42. package/templates/serverless/src/register.ts +21 -0
  43. package/templates/serverless/tsconfig.json +22 -0
  44. package/templates/simple/.env.example +3 -0
  45. package/templates/simple/package.json +13 -12
  46. package/templates/simple/src/app.ts +147 -0
  47. package/templates/simple/src/index.ts +57 -0
  48. package/templates/simple/tsconfig.json +20 -26
  49. package/templates/simple/vite.config.ts +6 -0
  50. package/templates/slack/.env.example +3 -0
  51. package/templates/slack/README.md +17 -0
  52. package/templates/slack/package.json +22 -0
  53. package/templates/slack/src/app.ts +45 -0
  54. package/templates/slack/src/index.ts +43 -0
  55. package/templates/slack/tsconfig.json +22 -0
  56. package/templates/slack/vite.config.ts +6 -0
  57. package/templates/default/src/commands/counter/counter.tsx +0 -53
  58. package/templates/default/src/commands/counter/index.ts +0 -7
  59. package/templates/rick-and-morty/src/commands/rick-and-morty/app.tsx +0 -28
  60. package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-display.tsx +0 -40
  61. package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-search-modal.tsx +0 -34
  62. package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-search.tsx +0 -29
  63. package/templates/rick-and-morty/src/commands/rick-and-morty/components/character-select.tsx +0 -36
  64. package/templates/rick-and-morty/src/commands/rick-and-morty/components/navigation.tsx +0 -58
  65. package/templates/rick-and-morty/src/commands/rick-and-morty/hooks/character-search-provider.tsx +0 -90
  66. package/templates/rick-and-morty/src/commands/rick-and-morty/hooks/useCharacters.ts +0 -38
  67. package/templates/rick-and-morty/src/commands/rick-and-morty/index.ts +0 -21
  68. package/templates/rick-and-morty/src/commands/rick-and-morty/types.ts +0 -24
  69. package/templates/simple/src/app.tsx +0 -38
  70. 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()