@flaredev/cli 0.1.0 → 0.1.1
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/dist/index.js +430 -252
- package/package.json +2 -2
- package/templates/app/README.md +7 -4
- package/templates/app/lib/auth.ts +45 -44
- package/templates/app/vite.config.ts +29 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flaredev/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The flare command-line tool: create, generate, migrate, and deploy Flare apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Muke Johnbaptist",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jiti": "^2.7.0",
|
|
41
41
|
"jsonc-parser": "^3.3.1",
|
|
42
42
|
"picocolors": "^1.1.1",
|
|
43
|
-
"@flaredev/core": "0.1.
|
|
43
|
+
"@flaredev/core": "0.1.1"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22"
|
package/templates/app/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# __APP_NAME__
|
|
2
2
|
|
|
3
|
-
A [Flare](https://
|
|
3
|
+
A [Flare](https://flare-docs.codetotech.com) app running on Cloudflare Workers via vinext.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
__PM__ run dev
|
|
7
|
-
|
|
8
|
-
__PM__ run
|
|
6
|
+
__PM__ run dev # start the dev server
|
|
7
|
+
npx flare dev --tunnel # ...and share it on a public https://*.trycloudflare.com URL
|
|
8
|
+
__PM__ run build # production build
|
|
9
|
+
__PM__ run deploy # build and deploy to Cloudflare Workers
|
|
9
10
|
```
|
|
11
|
+
|
|
12
|
+
Docs: https://flare-docs.codetotech.com
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import { env, waitUntil } from "cloudflare:workers";
|
|
2
|
-
import { betterAuth } from "better-auth";
|
|
3
|
-
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
|
|
4
|
-
import { nextCookies } from "better-auth/next-js";
|
|
5
|
-
import { admin } from "better-auth/plugins/admin";
|
|
6
|
-
import { hashPassword, verifyPassword } from "@flaredev/core";
|
|
7
|
-
import { getDb, schema } from "@/db";
|
|
8
|
-
|
|
9
|
-
/** Optional: set when serving from a custom domain (e.g. https://example.com). */
|
|
10
|
-
const configuredURL = (env as { BETTER_AUTH_URL?: string }).BETTER_AUTH_URL;
|
|
11
|
-
|
|
12
|
-
export const auth = betterAuth({
|
|
13
|
-
appName: "__APP_NAME__",
|
|
14
|
-
secret: env.BETTER_AUTH_SECRET,
|
|
15
|
-
// Without BETTER_AUTH_URL, accept local dev on any port
|
|
16
|
-
// host. Cloudflare only routes hosts this Worker serves, so
|
|
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
|
-
}
|
|
1
|
+
import { env, waitUntil } from "cloudflare:workers";
|
|
2
|
+
import { betterAuth } from "better-auth";
|
|
3
|
+
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
|
|
4
|
+
import { nextCookies } from "better-auth/next-js";
|
|
5
|
+
import { admin } from "better-auth/plugins/admin";
|
|
6
|
+
import { hashPassword, verifyPassword } from "@flaredev/core";
|
|
7
|
+
import { getDb, schema } from "@/db";
|
|
8
|
+
|
|
9
|
+
/** Optional: set when serving from a custom domain (e.g. https://example.com). */
|
|
10
|
+
const configuredURL = (env as { BETTER_AUTH_URL?: string }).BETTER_AUTH_URL;
|
|
11
|
+
|
|
12
|
+
export const auth = betterAuth({
|
|
13
|
+
appName: "__APP_NAME__",
|
|
14
|
+
secret: env.BETTER_AUTH_SECRET,
|
|
15
|
+
// Without BETTER_AUTH_URL, accept local dev on any port, a `flare dev --tunnel` URL and
|
|
16
|
+
// this app's workers.dev host. Cloudflare only routes hosts this Worker serves, so a
|
|
17
|
+
// deployed app never sees a trycloudflare.com host and the allowlist can't be spoofed.
|
|
18
|
+
baseURL: configuredURL || {
|
|
19
|
+
allowedHosts: ["localhost:*", "127.0.0.1:*", "*.trycloudflare.com", "__APP_NAME__.*.workers.dev"],
|
|
20
|
+
},
|
|
21
|
+
database: drizzleAdapter(getDb(), { provider: "sqlite", schema }),
|
|
22
|
+
socialProviders: __SOCIAL_PROVIDERS__,
|
|
23
|
+
emailAndPassword: {
|
|
24
|
+
enabled: true,
|
|
25
|
+
// PBKDF2 via WebCrypto: the default scrypt exceeds Workers CPU limits.
|
|
26
|
+
password: { hash: hashPassword, verify: verifyPassword },
|
|
27
|
+
},
|
|
28
|
+
advanced: {
|
|
29
|
+
// Let emails and other deferred work finish after the response is sent.
|
|
30
|
+
backgroundTasks: { handler: waitUntil },
|
|
31
|
+
},
|
|
32
|
+
plugins: [
|
|
33
|
+
// Adds user.role (default "user") and admin APIs. The /admin area allows ADMIN_ROLES (lib/admin.ts).
|
|
34
|
+
admin({ defaultRole: "user", adminRoles: ["admin"] }),
|
|
35
|
+
// Must stay last: lets server actions set auth cookies.
|
|
36
|
+
nextCookies(),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type Session = typeof auth.$Infer.Session;
|
|
41
|
+
|
|
42
|
+
/** OAuth providers with credentials configured, e.g. ["github"]. */
|
|
43
|
+
export function enabledSocialProviders(): string[] {
|
|
44
|
+
return Object.keys(auth.options.socialProviders ?? {});
|
|
45
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import vinext from "vinext";
|
|
3
|
-
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
4
|
-
import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import vinext from "vinext";
|
|
3
|
+
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
4
|
+
import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
// `flare dev --tunnel` serves the dev server on a https://*.trycloudflare.com URL.
|
|
8
|
+
server: { allowedHosts: [".trycloudflare.com"] },
|
|
9
|
+
plugins: [
|
|
10
|
+
vinext({
|
|
11
|
+
cache: {
|
|
12
|
+
// Data cache (`cached()`, fetch, "use cache") in Workers KV, shared by every colo.
|
|
13
|
+
// Entries live a day unless a tag revalidates them first; a colo may reuse its own
|
|
14
|
+
// copy for a minute after a write elsewhere.
|
|
15
|
+
data: kvDataAdapter({ ttlSeconds: 86_400, entryCacheTtlSeconds: 60 }),
|
|
16
|
+
// No `cdn` adapter yet. vinext's Workers Cache adapter (cdnAdapter) is experimental
|
|
17
|
+
// in the 1.0 beta: behind it, any page that redirects fails with "Too many
|
|
18
|
+
// redirects", and nothing is cached without an experimental two-stage deploy.
|
|
19
|
+
// See "Caching" in the Flare docs before turning it on.
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
cloudflare({
|
|
23
|
+
viteEnvironment: {
|
|
24
|
+
name: "rsc",
|
|
25
|
+
childEnvironments: ["ssr"],
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
});
|