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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Djobbo Maïga
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,59 +1,26 @@
|
|
|
1
1
|
# create-arona-app
|
|
2
2
|
|
|
3
|
-
Create a new Arona app with
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
3
|
+
Create a new [Arona](https://github.com/djobbo/arona) app with one command.
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
|
-
|
|
9
|
-
bun create arona-app my-app
|
|
10
|
-
|
|
11
|
-
# Using npm
|
|
12
|
-
npm create arona-app my-app
|
|
13
|
-
|
|
14
|
-
# Using yarn
|
|
15
|
-
yarn create arona-app my-app
|
|
16
|
-
|
|
17
|
-
# Using pnpm
|
|
18
|
-
pnpm create arona-app my-app
|
|
6
|
+
pnpm create arona-app my-bot
|
|
19
7
|
```
|
|
20
8
|
|
|
21
9
|
## Templates
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
- `alchemy` - Cloudflare Worker deployment of Arona with Alchemy, D1, and KV
|
|
12
|
+
- `counter` - The smallest Arona Discord bot: one slash command with a counter button
|
|
25
13
|
- `default` - A basic Arona app setup with essential features
|
|
26
14
|
- `rick-and-morty` - An example app that demonstrates API integration with the Rick and Morty API
|
|
15
|
+
- `serverless` - HTTP interactions with resumable Discord messages
|
|
27
16
|
- `simple` - A basic Arona app setup with essential features
|
|
28
|
-
|
|
29
|
-
## Features
|
|
30
|
-
|
|
31
|
-
- Interactive CLI with project name validation
|
|
32
|
-
- Template selection
|
|
33
|
-
- Package manager selection (npm, yarn, pnpm, bun)
|
|
34
|
-
- Automatic package.json configuration
|
|
35
|
-
- Clear next steps instructions
|
|
17
|
+
- `slack` - A Slack bot with interactive Block Kit messages
|
|
36
18
|
|
|
37
19
|
## Development
|
|
38
20
|
|
|
39
|
-
|
|
21
|
+
```bash
|
|
22
|
+
pnpm install
|
|
23
|
+
pnpm build
|
|
24
|
+
```
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
2. Install dependencies:
|
|
43
|
-
```bash
|
|
44
|
-
bun install
|
|
45
|
-
# or
|
|
46
|
-
npm install
|
|
47
|
-
# or
|
|
48
|
-
yarn install
|
|
49
|
-
# or
|
|
50
|
-
pnpm install
|
|
51
|
-
```
|
|
52
|
-
3. Link the package:
|
|
53
|
-
```bash
|
|
54
|
-
npm link
|
|
55
|
-
```
|
|
56
|
-
4. Test the package:
|
|
57
|
-
```bash
|
|
58
|
-
create-arona-app my-test-app
|
|
59
|
-
```
|
|
26
|
+
The build copies the workspace examples into `templates/` and rewrites them to standalone packages.
|
package/bin/create-arona-app.js
CHANGED
|
@@ -1,139 +1,142 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
3
|
+
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
4
|
+
import { Data, Effect } from "effect";
|
|
5
|
+
import { Command, Prompt } from "effect/cli";
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
10
9
|
|
|
11
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const PACKAGE_VERSION = JSON.parse(
|
|
12
|
+
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
13
|
+
).version;
|
|
12
14
|
|
|
13
15
|
const TEMPLATES = {
|
|
14
|
-
default:
|
|
15
|
-
|
|
16
|
+
default: "Default template with basic setup",
|
|
17
|
+
simple: "Small message-component example",
|
|
18
|
+
counter: "Counter component with gateway setup",
|
|
19
|
+
"rick-and-morty": "Rick and Morty example with API integration",
|
|
20
|
+
serverless: "HTTP interactions with a resumable message store",
|
|
21
|
+
slack: "Slack bot with Block Kit messages",
|
|
22
|
+
alchemy: "Cloudflare Worker deployed with Alchemy",
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
const PACKAGE_MANAGERS = {
|
|
19
26
|
npm: {
|
|
20
|
-
install:
|
|
21
|
-
dev:
|
|
27
|
+
install: "npm install",
|
|
28
|
+
dev: "npm run dev",
|
|
22
29
|
},
|
|
23
30
|
yarn: {
|
|
24
|
-
install:
|
|
25
|
-
dev:
|
|
31
|
+
install: "yarn",
|
|
32
|
+
dev: "yarn dev",
|
|
26
33
|
},
|
|
27
34
|
pnpm: {
|
|
28
|
-
install:
|
|
29
|
-
dev:
|
|
35
|
+
install: "pnpm install",
|
|
36
|
+
dev: "pnpm dev",
|
|
30
37
|
},
|
|
31
38
|
bun: {
|
|
32
|
-
install:
|
|
33
|
-
dev:
|
|
34
|
-
}
|
|
39
|
+
install: "bun install",
|
|
40
|
+
dev: "bun dev",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ScaffoldError = Data.TaggedError("ScaffoldError");
|
|
45
|
+
|
|
46
|
+
const detectPackageManager = () => {
|
|
47
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
48
|
+
return ["yarn", "pnpm", "bun"].find((manager) => userAgent.includes(manager)) ?? "npm";
|
|
35
49
|
};
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return 'npm';
|
|
43
|
-
}
|
|
51
|
+
const attempt = (operation, run) =>
|
|
52
|
+
Effect.tryPromise({
|
|
53
|
+
try: run,
|
|
54
|
+
catch: (cause) => new ScaffoldError({ operation, cause }),
|
|
55
|
+
});
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
const processReadme = (content, projectName, packageManager) => {
|
|
46
58
|
const pm = PACKAGE_MANAGERS[packageManager];
|
|
47
59
|
return content
|
|
48
60
|
.replace(/{{projectName}}/g, projectName)
|
|
49
61
|
.replace(/{{installCommand}}/g, pm.install)
|
|
50
62
|
.replace(/{{devCommand}}/g, pm.dev);
|
|
51
|
-
}
|
|
63
|
+
};
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
const scaffold = Effect.gen(function* () {
|
|
66
|
+
yield* Effect.log("✨ Welcome to create-arona-app! ✨");
|
|
55
67
|
|
|
56
|
-
const
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
message: 'What is your project named?',
|
|
61
|
-
default: 'my-arona-app',
|
|
68
|
+
const projectName = yield* Prompt.run(
|
|
69
|
+
Prompt.String({
|
|
70
|
+
message: "What is your project named?",
|
|
71
|
+
default: "my-arona-app",
|
|
62
72
|
validate: (input) => {
|
|
63
|
-
if (!input) return
|
|
64
|
-
if (fs.existsSync(input)) return
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
program
|
|
135
|
-
.name('create-arona-app')
|
|
136
|
-
.description('Create a new Arona app with a single command')
|
|
137
|
-
.action(createApp);
|
|
138
|
-
|
|
139
|
-
program.parse();
|
|
73
|
+
if (!input) return Effect.fail("Project name is required");
|
|
74
|
+
if (fs.existsSync(input)) return Effect.fail("Directory already exists");
|
|
75
|
+
return Effect.succeed(input);
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const template = yield* Prompt.run(
|
|
81
|
+
Prompt.Select({
|
|
82
|
+
message: "Which template would you like to use?",
|
|
83
|
+
choices: Object.entries(TEMPLATES).map(([value, description]) => ({
|
|
84
|
+
title: value,
|
|
85
|
+
value,
|
|
86
|
+
description,
|
|
87
|
+
})),
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const detectedPackageManager = detectPackageManager();
|
|
92
|
+
const packageManager = yield* Prompt.run(
|
|
93
|
+
Prompt.Select({
|
|
94
|
+
message: "Which package manager would you like to use?",
|
|
95
|
+
choices: Object.keys(PACKAGE_MANAGERS).map((value) => ({
|
|
96
|
+
title: value === detectedPackageManager ? `${value} (detected)` : value,
|
|
97
|
+
value,
|
|
98
|
+
})),
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
yield* Effect.log("Creating your Arona app...");
|
|
103
|
+
|
|
104
|
+
const templatePath = path.join(__dirname, "..", "templates", template);
|
|
105
|
+
yield* attempt("create directory", () => fs.mkdir(projectName));
|
|
106
|
+
yield* attempt("copy template", () => fs.copy(templatePath, projectName));
|
|
107
|
+
|
|
108
|
+
const packageJsonPath = path.join(projectName, "package.json");
|
|
109
|
+
const packageJson = yield* attempt("read package.json", () => fs.readJson(packageJsonPath));
|
|
110
|
+
packageJson.name = projectName;
|
|
111
|
+
yield* attempt("write package.json", () =>
|
|
112
|
+
fs.writeJson(packageJsonPath, packageJson, { spaces: 2 }),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const readmePath = path.join(projectName, "README.md");
|
|
116
|
+
const readmeContent = yield* attempt("read README", () => fs.readFile(readmePath, "utf-8"));
|
|
117
|
+
yield* attempt("write README", () =>
|
|
118
|
+
fs.writeFile(readmePath, processReadme(readmeContent, projectName, packageManager)),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const pm = PACKAGE_MANAGERS[packageManager];
|
|
122
|
+
yield* Effect.log("Project created successfully!");
|
|
123
|
+
yield* Effect.log("Next steps:");
|
|
124
|
+
yield* Effect.log(` cd ${projectName}`);
|
|
125
|
+
yield* Effect.log(` ${pm.install}`);
|
|
126
|
+
yield* Effect.log(` ${pm.dev}`);
|
|
127
|
+
yield* Effect.log("Happy coding! 🚀");
|
|
128
|
+
}).pipe(
|
|
129
|
+
Effect.catchCause((cause) =>
|
|
130
|
+
Effect.logError("Failed to create project", cause).pipe(
|
|
131
|
+
Effect.andThen(Effect.failCause(cause)),
|
|
132
|
+
),
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const command = Command.make("create-arona-app", {}, () => scaffold).pipe(
|
|
137
|
+
Command.withDescription("Create a new Arona app with a single command"),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
NodeRuntime.runMain(
|
|
141
|
+
Command.run(command, { version: PACKAGE_VERSION }).pipe(Effect.provide(NodeServices.layer)),
|
|
142
|
+
);
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arona-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Create a new Arona app with a single command",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"arona",
|
|
7
|
+
"create-arona-app",
|
|
8
|
+
"scaffold",
|
|
9
|
+
"template"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
4
12
|
"repository": {
|
|
5
13
|
"type": "git",
|
|
6
14
|
"url": "git+https://github.com/djobbo/arona.git"
|
|
7
15
|
},
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"description": "Create a new Arona app with a single command",
|
|
10
|
-
"type": "module",
|
|
11
16
|
"bin": {
|
|
12
17
|
"create-arona-app": "bin/create-arona-app.js"
|
|
13
18
|
},
|
|
@@ -15,25 +20,22 @@
|
|
|
15
20
|
"bin",
|
|
16
21
|
"templates"
|
|
17
22
|
],
|
|
18
|
-
"
|
|
19
|
-
"build": "bun run scripts/copy-templates.ts",
|
|
20
|
-
"prepublishOnly": "bun run build"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"arona",
|
|
24
|
-
"create-arona-app",
|
|
25
|
-
"scaffold",
|
|
26
|
-
"template"
|
|
27
|
-
],
|
|
28
|
-
"author": "",
|
|
23
|
+
"type": "module",
|
|
29
24
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"fs-extra": "^11.2.0"
|
|
33
|
-
"inquirer": "^9.2.12",
|
|
34
|
-
"ora": "^7.0.1"
|
|
25
|
+
"@effect/platform-node": "4.2.0",
|
|
26
|
+
"effect": "4.2.0",
|
|
27
|
+
"fs-extra": "^11.2.0"
|
|
35
28
|
},
|
|
36
29
|
"devDependencies": {
|
|
37
|
-
"
|
|
30
|
+
"@types/fs-extra": "^11.0.4",
|
|
31
|
+
"@types/node": "^26.6.10",
|
|
32
|
+
"typescript": "^5.8.3",
|
|
33
|
+
"vite-plus": "1.8.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "vpx scripts/copy-templates.ts",
|
|
37
|
+
"test": "vp test",
|
|
38
|
+
"check:types": "effect-tsgo tsrs --noEmit",
|
|
39
|
+
"check:lint": "effect-tsgo vp lint"
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
This project was created using [create-arona-app](https://github.com/djobbo/arona).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
First, install the dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
{{installCommand}}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then, run the development server:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
{{devCommand}}
|
|
17
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Alchemy from "alchemy";
|
|
2
|
+
import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import Api from "./src/worker.ts";
|
|
5
|
+
|
|
6
|
+
export default Alchemy.Stack(
|
|
7
|
+
"AronaDiscordAlchemy",
|
|
8
|
+
{
|
|
9
|
+
providers: Cloudflare.providers(),
|
|
10
|
+
state: Cloudflare.state(),
|
|
11
|
+
},
|
|
12
|
+
Effect.gen(function* () {
|
|
13
|
+
const api = yield* Api;
|
|
14
|
+
return { url: api.url };
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arona-ex/alchemy",
|
|
3
|
+
"private": true,
|
|
4
|
+
"description": "Cloudflare Worker deployment of Arona with Alchemy, D1, and KV",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "alchemy.run.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"deploy": "alchemy deploy",
|
|
9
|
+
"dev": "alchemy dev",
|
|
10
|
+
"register": "node --experimental-strip-types src/register.ts",
|
|
11
|
+
"check:types": "effect-tsgo tsrs --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@alchemy.run/cloudflare": "2.0.0-beta.87",
|
|
15
|
+
"@arona/core": "0.0.2",
|
|
16
|
+
"@arona/platform-discord": "0.0.2",
|
|
17
|
+
"@arona/platform-discord-alchemy": "0.0.2",
|
|
18
|
+
"@arona/store-cloudflare": "0.0.2",
|
|
19
|
+
"alchemy": "2.0.0-beta.87",
|
|
20
|
+
"effect": "4.2.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@cloudflare/workers-types": "^5.20261127.1",
|
|
24
|
+
"@types/node": "^26.6.10",
|
|
25
|
+
"typescript": "^5.8.3",
|
|
26
|
+
"vite-plus": "1.8.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { UiSchema } from "effect/ui";
|
|
2
|
+
import { ActionRow, Button, Container, SlashCommand, Text } from "@arona/platform-discord/worker";
|
|
3
|
+
import * as Discord from "@arona/platform-discord/worker";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
|
|
6
|
+
const CounterMessage = UiSchema.TaggedEnum({ Clicked: {} });
|
|
7
|
+
|
|
8
|
+
export const Counter = Discord.component({
|
|
9
|
+
name: "AlchemyCounter",
|
|
10
|
+
props: Schema.Struct({}),
|
|
11
|
+
model: Schema.Struct({ count: Schema.Finite }),
|
|
12
|
+
message: CounterMessage,
|
|
13
|
+
}).make({
|
|
14
|
+
init: () => ({ count: 0 }),
|
|
15
|
+
update: {
|
|
16
|
+
Clicked: ($) => $.evolve({ count: (count) => count + 1 }),
|
|
17
|
+
},
|
|
18
|
+
view: (h, model) =>
|
|
19
|
+
Container(h, {
|
|
20
|
+
children: [
|
|
21
|
+
Text(h, `# Count: ${model.count}`),
|
|
22
|
+
ActionRow(h, {
|
|
23
|
+
children: [
|
|
24
|
+
Button(h, {
|
|
25
|
+
style: "Primary",
|
|
26
|
+
onClick: CounterMessage.Clicked(),
|
|
27
|
+
children: ["Add one"],
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const counter = SlashCommand.make("counter", {
|
|
36
|
+
description: "A resumable counter",
|
|
37
|
+
component: Counter,
|
|
38
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DiscordRest, registerWorkerCommands } from "@arona/platform-discord/worker";
|
|
2
|
+
import { NodeRuntime } from "@effect/platform-node";
|
|
3
|
+
import { Config, Effect } from "effect";
|
|
4
|
+
import { counter } from "./counter.ts";
|
|
5
|
+
|
|
6
|
+
const program = Effect.gen(function* () {
|
|
7
|
+
const config = yield* Config.all({
|
|
8
|
+
token: Config.Redacted("DISCORD_APP_TOKEN"),
|
|
9
|
+
applicationId: Config.String("DISCORD_APP_ID"),
|
|
10
|
+
guildId: Config.option(Config.String("DISCORD_DEV_GUILD_ID")),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (counter.json === undefined) {
|
|
14
|
+
return yield* Effect.die(new Error("The counter command has no registration JSON"));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
yield* registerWorkerCommands({
|
|
18
|
+
applicationId: config.applicationId,
|
|
19
|
+
guildId: config.guildId,
|
|
20
|
+
commands: [counter.json],
|
|
21
|
+
}).pipe(Effect.provide(DiscordRest.layerFetch({ token: config.token })));
|
|
22
|
+
|
|
23
|
+
yield* Effect.log("Registered the counter command");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
NodeRuntime.runMain(program);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Cloudflare from "@alchemy.run/cloudflare";
|
|
2
|
+
import { migrationsDir } from "@arona/store-cloudflare/migrations";
|
|
3
|
+
|
|
4
|
+
export const Database = Cloudflare.D1.Database("Sessions", {
|
|
5
|
+
migrations: migrationsDir,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const Cache = Cloudflare.KV.Namespace("SessionCache");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Worker } from "@arona/platform-discord-alchemy";
|
|
2
|
+
import { Redacted } from "effect";
|
|
3
|
+
import { counter } from "./counter.ts";
|
|
4
|
+
import { Cache, Database } from "./resources.ts";
|
|
5
|
+
|
|
6
|
+
const requireEnv = (name: string): string => {
|
|
7
|
+
const value = process.env[name];
|
|
8
|
+
if (value === undefined || value === "") throw new Error(`Missing ${name}`);
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const env = {
|
|
13
|
+
token: Redacted.make(requireEnv("DISCORD_APP_TOKEN")),
|
|
14
|
+
publicKey: requireEnv("DISCORD_PUBLIC_KEY"),
|
|
15
|
+
build: process.env["BUILD_ID"] ?? "dev",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default Worker("Api", {
|
|
19
|
+
main: import.meta.url,
|
|
20
|
+
database: Database,
|
|
21
|
+
cache: Cache,
|
|
22
|
+
commands: [counter],
|
|
23
|
+
env: {
|
|
24
|
+
DISCORD_APP_TOKEN: env.token,
|
|
25
|
+
DISCORD_PUBLIC_KEY: env.publicKey,
|
|
26
|
+
BUILD_ID: env.build,
|
|
27
|
+
},
|
|
28
|
+
compatibility: { flags: ["nodejs_compat"], date: "2026-08-31" },
|
|
29
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"ESNext"
|
|
5
|
+
],
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleDetection": "force",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"exactOptionalPropertyTypes": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"noUncheckedIndexedAccess": true
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"src/**/*"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
This project was created using [create-arona-app](https://github.com/djobbo/arona).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
First, install the dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
{{installCommand}}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then, run the development server:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
{{devCommand}}
|
|
17
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arona-ex/counter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"description": "The smallest Arona Discord bot: one slash command with a counter button",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vp build --watch --mode development",
|
|
8
|
+
"build": "vp build",
|
|
9
|
+
"check:types": "effect-tsgo tsrs --noEmit"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@arona/core": "0.0.2",
|
|
13
|
+
"@arona/platform-discord": "0.0.2",
|
|
14
|
+
"effect": "4.2.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^26.6.10",
|
|
18
|
+
"typescript": "^5.8.3",
|
|
19
|
+
"vite-plus": "1.8.0"
|
|
20
|
+
}
|
|
21
|
+
}
|