Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
0.5.47
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelrk committed May 24, 2024
1 parent 0aea71c commit 4b93ec7
Show file tree
Hide file tree
Showing 40 changed files with 76 additions and 68 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"imports": {
"@/": "./",
"netzo/": "./lib/",
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
"fresh/": "https://deno.land/x/fresh@1.6.8/",
"preact": "https://esm.sh/preact@10.20.0",
"preact/": "https://esm.sh/preact@10.20.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.3",
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/dev/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// adapted from https://github.com/denoland/fresh/blob/main/src/dev/cli.ts
import { type FreshConfig } from "$fresh/server.ts";
import { manifest } from "$fresh/src/dev/mod.ts";
import { type FreshConfig } from "fresh/server.ts";
import { manifest } from "fresh/src/dev/mod.ts";
import { join, toFileUrl } from "../../deps/std/path/mod.ts";

const [cmd, configURL] = Deno.args;
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// latest version of netzo/cli (see https://github.com/netzo/netzo/releases)
export const VERSION = "0.5.46";
export const VERSION = "0.5.47";

// minimum version of Deno required to run this CLI
// (see https://github.com/denoland/deployctl/blob/main/src/version.ts)
Expand Down
2 changes: 1 addition & 1 deletion lib/components/blocks/netzo-toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @deno-types="npm:@types/react@18.2.60"
import * as React from "react";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { useSignal } from "@preact/signals";
import { IS_BROWSER } from "fresh/runtime.ts";
import { AuthUser } from "../../plugins/auth/utils/db.ts";
import { ButtonDarkMode } from "../button-dark-mode.tsx";
import { Button } from "../button.tsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/blocks/plot.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { createElement as h } from "preact";
import { useEffect, useRef } from "preact/compat";
import * as Plot from "../../deps/@observablehq/plot.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/button-dark-mode.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @deno-types="npm:@types/react@18.2.60"
import * as React from "react";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { Button, type ButtonProps } from "./button.tsx";
import { useDarkMode } from "./use-dark-mode.ts";
import { cn } from "./utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @deno-types="npm:@types/react@18.2.60"
import * as React from "react";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { Slot } from "../deps/@radix-ui/react-slot.ts";
import { cva, type VariantProps } from "../deps/class-variance-authority.ts";
import { cn } from "./utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/client-only.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import type { ComponentChildren } from "preact";

export const ClientOnly = ({ children }: { children: ComponentChildren }) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @deno-types="npm:@types/react@18.2.60"
import * as React from "react";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { cn } from "./utils.ts";

// deno-lint-ignore no-empty-interface
Expand Down
2 changes: 1 addition & 1 deletion lib/components/textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @deno-types="npm:@types/react@18.2.60"
import * as React from "react";

import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { cn } from "./utils.ts";

// deno-lint-ignore no-empty-interface
Expand Down
2 changes: 1 addition & 1 deletion lib/components/use-dark-mode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IS_BROWSER } from "$fresh/runtime.ts";
import { effect, signal } from "@preact/signals";
import { IS_BROWSER } from "fresh/runtime.ts";

// NOTE: initializes to false instead of getDarkMode() as default
export const darkMode = signal<boolean>(false);
Expand Down
2 changes: 1 addition & 1 deletion lib/database/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IMPORTANT: requires importing createClient from /web and not from root nor /node
// see https://github.com/tursodatabase/libsql-client-ts/issues/138#issuecomment-1921954374
import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";
import { createClient } from "npm:/@libsql/client@0.6.0";
import { drizzle } from "npm:/drizzle-orm@0.30.10/libsql";
import { drizzle as drizzleSqliteProxy } from "npm:/drizzle-orm@0.30.10/sqlite-proxy";
Expand Down
2 changes: 1 addition & 1 deletion lib/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type FreshConfig } from "$fresh/server.ts";
import { type FreshConfig } from "fresh/server.ts";
import type { LoaderState } from "netzo/plugins/loader/plugin.ts";
import type { MdxState } from "netzo/plugins/mdx/plugin.ts";
import type { AuthState } from "./plugins/auth/plugin.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/auth/middlewares/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FreshContext } from "$fresh/server.ts";
import type { FreshContext } from "fresh/server.ts";
import { getSessionId } from "../../../deps/deno_kv_oauth/mod.ts";
import type { NetzoState } from "../../../mod.ts";
import { AuthConfig, AuthState } from "../plugin.ts";
Expand Down
16 changes: 8 additions & 8 deletions lib/plugins/auth/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { FreshContext, Plugin, PluginRoute } from "$fresh/server.ts";
import type { FreshContext, Plugin, PluginRoute } from "fresh/server.ts";
import type { OAuth2ClientConfig } from "../../deps/oauth2_client/src/oauth2_client.ts";
import type { NetzoState } from "../../mod.ts";
import {
assertUserIsMemberOfWorkspaceOfApiKeyIfProviderIsNetzo,
createAssertUserIsAuthorized,
ensureSignedIn,
NetzoStateWithAuth,
setAuthState,
setRequestState,
setSessionState,
NetzoStateWithAuth,
assertUserIsMemberOfWorkspaceOfApiKeyIfProviderIsNetzo,
createAssertUserIsAuthorized,
ensureSignedIn,
setAuthState,
setRequestState,
setSessionState,
} from "./middlewares/mod.ts";
import createAuth from "./routes/auth.tsx";
import { getRoutesByProvider } from "./routes/mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/auth/routes/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineRoute, type RouteConfig } from "$fresh/server.ts";
import { defineRoute, type RouteConfig } from "fresh/server.ts";
import { cn } from "../../../components/utils.ts";
import { AuthForm } from "../islands/auth-form.tsx";
import { type AuthConfig } from "../plugin.ts";
Expand Down
8 changes: 4 additions & 4 deletions lib/plugins/auth/routes/mod.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PluginRoute } from "$fresh/server.ts";
import type { PluginRoute } from "fresh/server.ts";
import type { AuthConfig } from "../plugin.ts";
import {
getAuthConfig,
getFunctionsByProvider,
getUserByProvider,
getAuthConfig,
getFunctionsByProvider,
getUserByProvider,
} from "../utils/providers/mod.ts";
import type { AuthProvider, AuthUser } from "../utils/types.ts";

Expand Down
20 changes: 10 additions & 10 deletions lib/plugins/auth/utils/providers/mod.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { FreshContext } from "$fresh/server.ts";
import { FreshContext } from "fresh/server.ts";
import {
createAuth0OAuthConfig,
createGitHubOAuthConfig,
createGitLabOAuthConfig,
createGoogleOAuthConfig,
createOktaOAuthConfig,
createSlackOAuthConfig,
handleCallback,
signIn,
signOut,
createAuth0OAuthConfig,
createGitHubOAuthConfig,
createGitLabOAuthConfig,
createGoogleOAuthConfig,
createOktaOAuthConfig,
createSlackOAuthConfig,
handleCallback,
signIn,
signOut,
} from "../../../../deps/deno_kv_oauth/mod.ts";
import type { AuthProvider, AuthUserFromProvider } from "../types.ts";
import { getUserAuth0 } from "./auth0.ts";
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/cron/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "$fresh/server.ts";
import type { Plugin } from "fresh/server.ts";
import type { NetzoState } from "../../mod.ts";
import { proxyCron } from "./mod.ts";

Expand Down
12 changes: 10 additions & 2 deletions lib/plugins/database/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import type { Plugin, PluginRoute } from "$fresh/server.ts";
import type { Plugin, PluginRoute } from "fresh/server.ts";
import { createClient } from "npm:@libsql/client@0.6.0";
import { eq } from "npm:drizzle-orm@0.30.10";
import { DrizzleConfig } from "npm:drizzle-orm@0.30.10/utils";
Expand Down Expand Up @@ -97,7 +97,15 @@ export const database = (config?: DatabaseConfig): Plugin => {
const { tableName } = ctx.params;
const table = config.schema![tableName] as any;
const data = await parseRequestBody(req);
const result = await db.insert(table).values(data).returning();
// UPSERT: https://orm.drizzle.team/learn/guides/upsert
const result = await db
.insert(table)
.values(data)
.onConflictDoUpdate({
target: table.id,
set: { id: sql.raw(`excluded.${table.id}`) },
})
.returning();
return Response.json(
Array.isArray(result) ? result[0] : result.rows,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/datastore/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Plugin, PluginRoute } from "$fresh/server.ts";
import type { Plugin, PluginRoute } from "fresh/server.ts";
import { deepParseJson } from "npm:deep-parse-json@2.0.0";
import { unflatten } from "npm:flat@6.0.1";
import { datastore as createDatastore } from "../../datastore/mod.ts";
import { apiKeyAuthentication, cors } from "../middleware.ts";
import { parseRequestBody, RESPONSES } from "../utils.ts";
import { RESPONSES, parseRequestBody } from "../utils.ts";

export type DatastoreConfig = {
/** Wether to require authentication using the provided API key in the
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/environments/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin } from "$fresh/server.ts";
import type { Plugin } from "fresh/server.ts";
import type { NetzoState } from "../../mod.ts";
import { setEnvVarsIfRemoteProject } from "./mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/loader/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// see https://github.com/nesterow/tailored#preloader-plugin
import { Plugin } from "$fresh/server.ts";
import { Plugin } from "fresh/server.ts";
import type { NetzoState } from "netzo/config/mod.ts";

export type LoaderOptions = {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/mdx/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, PluginRoute } from "../../deps/$fresh/server.ts";
import type { Plugin, PluginRoute } from "../../deps/fresh/server.ts";
import type { NetzoState } from "../../mod.ts";
import { mdxPathsToRoutes, scanForMDXFiles } from "./utils.ts";

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/mdx/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PluginRoute } from "$fresh/server.ts";
import { type PluginRoute } from "fresh/server.ts";
import { compile } from "npm:@mdx-js/mdx";
import { ImportDeclaration } from "npm:@types/estree-jsx@1.0.5";
import { Root } from "npm:@types/hast@3.0.3";
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MiddlewareHandler } from "$fresh/server.ts";
import { MiddlewareHandler } from "fresh/server.ts";
import { RESPONSES } from "./utils.ts";

const enableCors = (req: Request, res: Response) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/storage/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, PluginRoute } from "$fresh/server.ts";
import type { Plugin, PluginRoute } from "fresh/server.ts";
import { apiKeyAuthentication, cors } from "../middleware.ts";

export type StorageConfig = {
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/unocss/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from "$fresh/server.ts";
import { dirname, fromFileUrl, join, walk } from "$fresh/src/server/deps.ts";
import { JSX, options as preactOptions, VNode } from "preact";
import type { Plugin } from "fresh/server.ts";
import { dirname, fromFileUrl, join, walk } from "fresh/src/server/deps.ts";
import { JSX, VNode, options as preactOptions } from "preact";
import { UnoGenerator, type UserConfig } from "../../deps/@unocss/core.ts";
import type { Theme } from "../../deps/@unocss/preset-uno.ts";
import { existsSync } from "../../deps/std/fs/exists.ts";
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture-plugins-mdx/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"lock": false,
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"cli": "echo \"import '\\fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
Expand All @@ -23,7 +23,7 @@
"imports": {
"@/": "./",
"netzo/": "../../lib/",
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
"fresh/": "https://deno.land/x/fresh@1.6.8/",
"preact": "https://esm.sh/preact@10.20.0",
"preact/": "https://esm.sh/preact@10.20.0/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.3.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts";
import dev from "fresh/dev.ts";
import config from "./fresh.config.ts";

import "$std/dotenv/load.ts";
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "$fresh/server.ts";
import { defineConfig } from "fresh/server.ts";
import { mdx } from "netzo/plugins/mdx/plugin.ts";
import { unocss } from "netzo/plugins/unocss/plugin.ts";
import unocssConfig from "./unocss.config.ts";
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture-plugins-mdx/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.

import * as $_app from "./routes/_app.tsx";
import { type Manifest } from "fresh/server.ts";
import * as $Counter from "./islands/Counter.tsx";
import { type Manifest } from "$fresh/server.ts";
import * as $_app from "./routes/_app.tsx";

const manifest = {
routes: {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/islands/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Signal } from "@preact/signals";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { IS_BROWSER } from "fresh/runtime.ts";

interface CounterProps {
count: Signal<number>;
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture-plugins-mdx/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import "$std/dotenv/load.ts";

import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import { start } from "fresh/server.ts";
import config from "./fresh.config.ts";
import manifest from "./fresh.gen.ts";

await start(manifest, config);
2 changes: 1 addition & 1 deletion tests/fixture-plugins-mdx/routes/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PageProps } from "$fresh/server.ts";
import { type PageProps } from "fresh/server.ts";
export default function App({ Component }: PageProps) {
return (
<html>
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-unocss/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"imports": {
"@/": "./",
"netzo/": "../../lib/",
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
"fresh/": "https://deno.land/x/fresh@1.6.8/",
"preact": "https://esm.sh/preact@10.20.0",
"preact/": "https://esm.sh/preact@10.20.0/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.3.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-unocss/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts";
import dev from "fresh/dev.ts";

await dev(import.meta.url, "./main.ts"); // DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-unocss/fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "$fresh/server.ts";
import { defineConfig } from "fresh/server.ts";
import { unocss } from "netzo/plugins/unocss/plugin.ts";
import unocssConfig from "./uno.config.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/fixture-plugins-unocss/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.

import * as $index from "./routes/index.tsx";
import { type Manifest } from "fresh/server.ts";
import * as $CheckDuplication from "./islands/CheckDuplication.tsx";
import * as $InsertCssRules from "./islands/InsertCssRules.tsx";
import { type Manifest } from "$fresh/server.ts";
import * as $index from "./routes/index.tsx";

const manifest = {
routes: {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture-plugins-unocss/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />

import { start } from "$fresh/server.ts";
import { start } from "fresh/server.ts";
import config from "./fresh.config.ts";
import manifest from "./fresh.gen.ts";

Expand Down

0 comments on commit 4b93ec7

Please sign in to comment.