coloco 0.4.7__tar.gz → 0.4.8__tar.gz

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 (60) hide show
  1. {coloco-0.4.7 → coloco-0.4.8}/PKG-INFO +1 -1
  2. {coloco-0.4.7 → coloco-0.4.8}/pyproject.toml +1 -1
  3. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/createapp.py +3 -5
  4. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/dev.py +2 -2
  5. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/node.py +2 -2
  6. coloco-0.4.8/src/coloco/codegen.py +92 -0
  7. coloco-0.4.8/src/coloco/config.py +22 -0
  8. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/exceptions.py +1 -0
  9. coloco-0.4.8/src/coloco/templates/standard/.gitignore-tpl +20 -0
  10. coloco-0.4.8/src/coloco/templates/standard/README.md-tpl +3 -0
  11. {coloco-0.4.7/src/coloco/templates/standard/+node → coloco-0.4.8/src/coloco/templates/standard}/package.json-tpl +10 -5
  12. coloco-0.4.8/src/coloco/templates/standard/pyproject.toml-tpl +17 -0
  13. coloco-0.4.8/src/coloco/templates/standard/src/app/example/index.svelte-tpl +13 -0
  14. coloco-0.4.8/src/coloco/templates/standard/src/app/index.svelte-tpl +1 -0
  15. coloco-0.4.8/src/coloco/templates/standard/src/app.svelte-tpl +38 -0
  16. coloco-0.4.8/src/coloco/templates/standard/src/assets/favicon.png-tpl +0 -0
  17. coloco-0.4.8/src/coloco/templates/standard/src/lib/client.ts-tpl +15 -0
  18. coloco-0.4.8/src/coloco/templates/standard/src/main.py-tpl +6 -0
  19. {coloco-0.4.7/src/coloco/templates/standard/+app → coloco-0.4.8/src/coloco/templates/standard/src}/main.ts-tpl +1 -2
  20. coloco-0.4.8/src/coloco/templates/standard/tsconfig.json-tpl +36 -0
  21. coloco-0.4.8/src/coloco/templates/standard/vite-env.d.ts-tpl +11 -0
  22. coloco-0.4.8/src/coloco/templates/standard/vite.config.ts-tpl +30 -0
  23. coloco-0.4.7/src/coloco/codegen.py +0 -62
  24. coloco-0.4.7/src/coloco/config.py +0 -18
  25. coloco-0.4.7/src/coloco/templates/standard/+app/app.svelte-tpl +0 -29
  26. coloco-0.4.7/src/coloco/templates/standard/+app/index.svelte-tpl +0 -1
  27. coloco-0.4.7/src/coloco/templates/standard/+node/openapi-ts.config.ts-tpl +0 -10
  28. coloco-0.4.7/src/coloco/templates/standard/+node/tsconfig.json-tpl +0 -43
  29. coloco-0.4.7/src/coloco/templates/standard/+node/vite-env.d.ts-tpl +0 -2
  30. coloco-0.4.7/src/coloco/templates/standard/+node/vite.config.ts-tpl +0 -48
  31. coloco-0.4.7/src/coloco/templates/standard/.gitignore-tpl +0 -6
  32. coloco-0.4.7/src/coloco/templates/standard/README.md-tpl +0 -3
  33. coloco-0.4.7/src/coloco/templates/standard/example/index.svelte-tpl +0 -7
  34. coloco-0.4.7/src/coloco/templates/standard/main.py-tpl +0 -3
  35. coloco-0.4.7/src/coloco/templates/standard/pyproject.toml-tpl +0 -13
  36. coloco-0.4.7/src/coloco/templates/standard/tsconfig.json-tpl +0 -3
  37. {coloco-0.4.7 → coloco-0.4.8}/LICENSE +0 -0
  38. {coloco-0.4.7 → coloco-0.4.8}/README.md +0 -0
  39. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/__init__.py +0 -0
  40. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/__main__.py +0 -0
  41. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/api.py +0 -0
  42. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/app.py +0 -0
  43. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/api.py +0 -0
  44. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/build.py +0 -0
  45. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/db.py +0 -0
  46. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/package.py +0 -0
  47. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/cli/serve.py +0 -0
  48. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/db.py +0 -0
  49. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/dependencies.py +0 -0
  50. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/lifespan.py +0 -0
  51. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/static.py +0 -0
  52. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/templates/docker/.dockerignore-tpl +0 -0
  53. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/templates/docker/Dockerfile-tpl +0 -0
  54. {coloco-0.4.7 → coloco-0.4.8}/src/coloco/templates/docker/docker-compose.yml-tpl +0 -0
  55. {coloco-0.4.7/src/coloco/templates/standard/+app → coloco-0.4.8/src/coloco/templates/standard/src/app}/404.svelte-tpl +0 -0
  56. {coloco-0.4.7/src/coloco/templates/standard → coloco-0.4.8/src/coloco/templates/standard/src/app}/example/api.py-tpl +0 -0
  57. {coloco-0.4.7/src/coloco/templates/standard/+app → coloco-0.4.8/src/coloco/templates/standard/src}/app.css-tpl +0 -0
  58. {coloco-0.4.7/src/coloco/templates/standard/+app → coloco-0.4.8/src/coloco/templates/standard/src}/index.html-tpl +0 -0
  59. {coloco-0.4.7/src/coloco/templates/standard/+node → coloco-0.4.8/src/coloco/templates/standard}/svelte.config.js-tpl +0 -0
  60. {coloco-0.4.7 → coloco-0.4.8}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coloco
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: A kit for creating FastAPI + Svelte applications
5
5
  Author-Email: Channel Cat <channelcat@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "coloco"
3
- version = "0.4.7"
3
+ version = "0.4.8"
4
4
  description = "A kit for creating FastAPI + Svelte applications"
5
5
  authors = [
6
6
  { name = "Channel Cat", email = "channelcat@gmail.com" },
@@ -1,6 +1,5 @@
1
- from rich import print
2
- from .node import install
3
1
  import os
2
+ from rich import print
4
3
 
5
4
 
6
5
  def createapp(name: str):
@@ -11,6 +10,7 @@ def createapp(name: str):
11
10
 
12
11
  template_vars = {
13
12
  "project_name": name,
13
+ "coloco_version": "0.4.8",
14
14
  }
15
15
 
16
16
  # Create directory
@@ -28,9 +28,7 @@ def createapp(name: str):
28
28
  content = f.read()
29
29
  for key, value in template_vars.items():
30
30
  content = content.replace(f"{{{{ {key} }}}}", value)
31
- with open(
32
- os.path.join(install_dir, relative_path, file[:-4]), "w"
33
- ) as f:
31
+ with open(os.path.join(install_dir, relative_path, file[:-4]), "w") as f:
34
32
  f.write(content)
35
33
 
36
34
  print(f"App created in {install_dir}")
@@ -10,7 +10,7 @@ app = cyclopts.App()
10
10
 
11
11
 
12
12
  @app.default()
13
- def dev(app: str | None = None, host: str = "127.0.0.1"):
13
+ def dev(app: str | None = None, host: str = "127.0.0.1", port: int = 5172):
14
14
  if not app:
15
15
  app = get_coloco_config().get("app") or "src.main.app"
16
16
 
@@ -26,7 +26,7 @@ def dev(app: str | None = None, host: str = "127.0.0.1"):
26
26
  _serve(
27
27
  app=app,
28
28
  host=host,
29
- port=5172,
29
+ port=port,
30
30
  log_level="debug",
31
31
  mode="dev",
32
32
  reload=True,
@@ -23,8 +23,8 @@ def _run_npm(command):
23
23
  raise SystemExit(1)
24
24
 
25
25
 
26
- def _setup_dev_env():
27
- os.environ["API_HOST"] = "http://localhost:5172"
26
+ def _setup_dev_env(port: int = 5172):
27
+ os.environ["VITE_API_HOST"] = f"http://localhost:{port}"
28
28
 
29
29
 
30
30
  @app.command()
@@ -0,0 +1,92 @@
1
+ from contextlib import contextmanager
2
+ from fastapi import FastAPI
3
+ from fastapi.routing import APIRoute
4
+ import json
5
+ from subprocess import run
6
+
7
+ import os
8
+ import shutil
9
+ import filecmp
10
+
11
+
12
+ def compare_and_copy(source_dir, target_dir):
13
+ """
14
+ Compares files in two directories and copies files from source to target if they differ, creating target directories if needed.
15
+
16
+ Args:
17
+ source_dir (str): Path to the source directory.
18
+ target_dir (str): Path to the target directory.
19
+ """
20
+ for root, _, files in os.walk(source_dir):
21
+ rel_path = os.path.relpath(root, source_dir) # Get relative path from source
22
+ target_path = os.path.join(target_dir, rel_path)
23
+ os.makedirs(target_path, exist_ok=True) # Create target directory if it doesn't exist
24
+
25
+ for file in files:
26
+ source_file = os.path.join(root, file)
27
+ target_file = os.path.join(target_path, file)
28
+
29
+ if not os.path.exists(target_file) or not filecmp.cmp(source_file, target_file):
30
+ shutil.copy2(source_file, target_file)
31
+
32
+
33
+ def custom_generate_unique_id(route: APIRoute) -> str:
34
+ return f"{route.name}"
35
+
36
+
37
+ def generate_openapi_schema(app: FastAPI, path="/tmp/openapi.json"):
38
+ with open(path, "w") as f:
39
+ json.dump(app.openapi(), f)
40
+
41
+
42
+ @contextmanager
43
+ def ensure_openapi_ts_config(config_path="./openapi-ts.config.ts", output_path="./api/app"):
44
+ """
45
+ Ensures an openapi-ts config file is present, otherwise temporarily generates one
46
+ """
47
+ generated = False
48
+ try:
49
+ if not os.path.exists(config_path):
50
+ with open(config_path, "w") as f:
51
+ generated = True
52
+ f.write(
53
+ f"""
54
+ import {{ defaultPlugins }} from '@hey-api/openapi-ts';
55
+ import {{ codegenConfig }} from '@coloco/api-client-svelte';
56
+
57
+ export default {{
58
+ plugins: [
59
+ ...defaultPlugins,
60
+ '@hey-api/client-fetch',
61
+ codegenConfig({{ name: 'coloco-codegen', outputPath: '{output_path}' }}),
62
+ ],
63
+ }};
64
+ """
65
+ )
66
+ yield
67
+ finally:
68
+ if generated:
69
+ os.remove(config_path)
70
+
71
+
72
+ def generate_openapi_code(
73
+ host,
74
+ spec_path="/tmp/openapi.json",
75
+ output_dir="./src/app/.generated/client",
76
+ config_path="./openapi-ts.config.ts",
77
+ diff_files=False,
78
+ ):
79
+ temp_dir = "/tmp/backend_api"
80
+ output_path = os.path.join(os.getcwd(), output_dir)
81
+
82
+ with ensure_openapi_ts_config(config_path):
83
+ run(
84
+ f"npx openapi-ts "
85
+ f"--base {host} "
86
+ f"--file {config_path} "
87
+ f"--input {spec_path} "
88
+ f"--output {temp_dir if diff_files else output_path} ".split(),
89
+ cwd=os.getcwd(),
90
+ )
91
+ if diff_files:
92
+ compare_and_copy(temp_dir, output_dir)
@@ -0,0 +1,22 @@
1
+ import tomllib
2
+ import os
3
+
4
+
5
+ def get_pyproject_config(path: str = "pyproject.toml"):
6
+ # Read project toml
7
+ if not os.path.exists(path):
8
+ raise LookupError(f"{path} not found")
9
+ with open(path, "rb") as f:
10
+ config = tomllib.load(f)
11
+ return config
12
+
13
+
14
+ def get_coloco_config():
15
+ # Read project toml
16
+ config = get_pyproject_config()
17
+
18
+ # Get coloco config
19
+ coloco_config = config.get("tool", {}).get("coloco")
20
+ if not coloco_config:
21
+ raise LookupError("coloco config not found in pyproject.toml under [tool.coloco]")
22
+ return coloco_config
@@ -11,6 +11,7 @@ class UserError(Exception):
11
11
  def __init__(self, *args: object, status_code=400, code="bad_request") -> None:
12
12
  super().__init__(*args)
13
13
  self.code = code
14
+ self.status_code = status_code
14
15
 
15
16
 
16
17
  class ServerError(Exception):
@@ -0,0 +1,20 @@
1
+ # Node
2
+ node_modules
3
+ .vite
4
+
5
+ # Python
6
+ __pycache__
7
+
8
+ # UV generated
9
+ .venv
10
+ .python-version
11
+
12
+ # App Generated
13
+ dist
14
+ src/app/.generated
15
+
16
+ # Local database
17
+ db.sqlite3*
18
+
19
+ # Local settings
20
+ .env
@@ -0,0 +1,3 @@
1
+ # {{ project_name }}
2
+
3
+ Created using Coloco, A kit for creating FastAPI + Svelte applications
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "{{ project_name }}",
2
+ "name": "couchquest",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
5
  "type": "module",
@@ -10,16 +10,21 @@
10
10
  "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
11
11
  },
12
12
  "devDependencies": {
13
- "@coloco/api-client-svelte": "^0.4.10",
14
- "@coloco/router": "^0.1.15",
13
+ "@coloco/api-client-svelte": "^0.4.12",
14
+ "@coloco/router": "^0.1.18",
15
+ "@coloco/vite": "^0.1.1",
15
16
  "@hey-api/client-fetch": "^0.8.2",
16
17
  "@hey-api/openapi-ts": "^0.64.7",
17
18
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
18
19
  "@tsconfig/svelte": "^5.0.4",
19
20
  "@types/node": "^22.13.4",
21
+ "autoprefixer": "^10.4.20",
20
22
  "svelte": "^5.19.6",
21
23
  "svelte-check": "^4.1.4",
22
- "typescript": "~5.7.2",
23
- "vite": "^6.1.0"
24
+ "typescript": "~5.8.2",
25
+ "vite": "^6.3.3"
26
+ },
27
+ "dependencies": {
28
+ "@mateothegreat/svelte5-router": "^2.14.1"
24
29
  }
25
30
  }
@@ -0,0 +1,17 @@
1
+ [project]
2
+ name = "{{ project_name }}"
3
+ version = "0.1.0"
4
+ description = "Your project description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "coloco>={{ coloco_version }}",
9
+ "tortoise-pathway>=0.2.0",
10
+ ]
11
+
12
+ [tool.coloco]
13
+ app = "src.main.app"
14
+ migrations_dir = "+migrations"
15
+
16
+ [tool.uv.sources]
17
+ tortoise-pathway = { git = "https://github.com/channelcat/tortoise-pathway", rev = "iterate-migration-apply" }
@@ -0,0 +1,13 @@
1
+ <script lang="ts">
2
+ import { test } from "./api";
3
+
4
+ const results = test({ name: "Testy McTesterson" });
5
+ </script>
6
+
7
+ {#await results}
8
+ <p>Loading...</p>
9
+ {:then response}
10
+ <p>Hello {response.data}</p>
11
+ {:catch error}
12
+ <p>Error: {error}</p>
13
+ {/await}
@@ -0,0 +1 @@
1
+ I am the home page!
@@ -0,0 +1,38 @@
1
+ <script lang="ts">
2
+ import "./app.css";
3
+
4
+ import { Router, getRoutes, route } from "@coloco/router";
5
+ import { setDefaultClient } from "@coloco/api-client-svelte";
6
+
7
+ import FavIcon from "@/assets/favicon.png";
8
+
9
+ import Index from "@app/index.svelte";
10
+ import NotFound from "@app/404.svelte";
11
+
12
+ import { client } from "./lib/client";
13
+
14
+ setDefaultClient(client);
15
+
16
+ const routes = getRoutes({
17
+ index: Index,
18
+ notFound: NotFound,
19
+ });
20
+ </script>
21
+
22
+ <svelte:head>
23
+ <link rel="icon" type="image/x-icon" href={FavIcon} />
24
+ </svelte:head>
25
+
26
+ <main>
27
+ Main Page
28
+
29
+ <br /><br />
30
+
31
+ <a use:route href="/">Home</a><br />
32
+ <a use:route href="/example">Example</a><br />
33
+ <a use:route href="/missing">Missing</a>
34
+
35
+ <br /><br />
36
+
37
+ <Router basePath="/" {routes} />
38
+ </main>
@@ -0,0 +1,15 @@
1
+ import { makeClient } from "@coloco/api-client-svelte";
2
+
3
+ export const client = makeClient({
4
+ baseUrl: import.meta.env.VITE_API_HOST,
5
+ throwOnError: true,
6
+ fetch: (request) => {
7
+ return fetch(request, {
8
+ credentials: "include",
9
+ });
10
+ },
11
+ errorHandler: (error) => {
12
+ console.error(error.stack);
13
+ alert(error.message);
14
+ },
15
+ });
@@ -0,0 +1,6 @@
1
+ from coloco import create_app
2
+
3
+ app = create_app(
4
+ name="{{ project_name }}",
5
+ database_url="sqlite://db.sqlite3",
6
+ )
@@ -1,9 +1,8 @@
1
1
  import { mount } from 'svelte'
2
- import './app.css'
3
2
  import App from './app.svelte'
4
3
 
5
4
  const app = mount(App, {
6
- target: document.getElementById('app')!,
5
+ target: document.getElementById('app') as HTMLElement,
7
6
  })
8
7
 
9
8
  export default app
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Coloco auto-generated APIs
4
+ "rootDirs": ["./src", "./src/app/.generated/client/api"],
5
+ "verbatimModuleSyntax": true,
6
+ "isolatedModules": true,
7
+ "lib": ["esnext", "DOM", "DOM.Iterable"],
8
+ "moduleResolution": "bundler",
9
+ "module": "esnext",
10
+ "noEmit": true,
11
+ "target": "esnext",
12
+ // Project
13
+ "allowJs": true,
14
+ "checkJs": true,
15
+ "esModuleInterop": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "resolveJsonModule": true,
18
+ "skipLibCheck": true,
19
+ "sourceMap": true,
20
+ "strict": true,
21
+ // Coloco Paths
22
+ "paths": {
23
+ "@api/*": ["./src/app/.generated/client/api/app/*"],
24
+ "@app/*": ["./src/app/*"],
25
+ "@client/*": ["./src/app/.generated/client/*"],
26
+ "@/*": ["./src/*", "./src/app/.generated/client/api/*"]
27
+ }
28
+ },
29
+ "include": [
30
+ "./src/**/*.ts",
31
+ "./src/**/*.js",
32
+ "./src/**/*.svelte",
33
+ "./vite.config.ts",
34
+ "./vite-env.d.ts"
35
+ ]
36
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
3
+
4
+ interface ImportMetaEnv {
5
+ readonly VITE_API_HOST: string
6
+ // Add other environment variables here as needed
7
+ }
8
+
9
+ interface ImportMeta {
10
+ readonly env: ImportMetaEnv
11
+ }
@@ -0,0 +1,30 @@
1
+ import path, { dirname, resolve, relative } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { defineConfig } from "vite";
4
+ import { svelte } from "@sveltejs/vite-plugin-svelte";
5
+ import tailwindcss from "@tailwindcss/vite";
6
+ import { coloco, colocoAliases } from "@coloco/vite";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const root = resolve(__dirname, "./src");
10
+
11
+ // https://vite.dev/config/
12
+ export default defineConfig({
13
+ plugins: [tailwindcss(), svelte(), coloco()],
14
+ root: root,
15
+ server: {
16
+ host: "0.0.0.0",
17
+ port: 5173,
18
+ },
19
+ build: {
20
+ outDir: "../dist/app",
21
+ emptyOutDir: true,
22
+ },
23
+ clearScreen: false,
24
+ resolve: {
25
+ alias: [
26
+ ...colocoAliases(),
27
+ { find: "$lib", replacement: path.resolve("./src/lib") },
28
+ ],
29
+ },
30
+ });
@@ -1,62 +0,0 @@
1
- from fastapi import FastAPI
2
- from fastapi.routing import APIRoute
3
- import json
4
- from subprocess import run
5
-
6
- import os
7
- import shutil
8
- import filecmp
9
-
10
-
11
- def compare_and_copy(source_dir, target_dir):
12
- """
13
- Compares files in two directories and copies files from source to target if they differ, creating target directories if needed.
14
-
15
- Args:
16
- source_dir (str): Path to the source directory.
17
- target_dir (str): Path to the target directory.
18
- """
19
- for root, _, files in os.walk(source_dir):
20
- rel_path = os.path.relpath(root, source_dir) # Get relative path from source
21
- target_path = os.path.join(target_dir, rel_path)
22
- os.makedirs(
23
- target_path, exist_ok=True
24
- ) # Create target directory if it doesn't exist
25
-
26
- for file in files:
27
- source_file = os.path.join(root, file)
28
- target_file = os.path.join(target_path, file)
29
-
30
- if not os.path.exists(target_file) or not filecmp.cmp(
31
- source_file, target_file
32
- ):
33
- shutil.copy2(source_file, target_file)
34
-
35
-
36
- def custom_generate_unique_id(route: APIRoute) -> str:
37
- return f"{route.name}"
38
-
39
-
40
- def generate_openapi_schema(app: FastAPI, path="/tmp/openapi.json"):
41
- with open(path, "w") as f:
42
- json.dump(app.openapi(), f)
43
-
44
-
45
- def generate_openapi_code(
46
- host,
47
- spec_path="/tmp/openapi.json",
48
- output_dir="./src/app/.generated/client",
49
- diff_files=False,
50
- ):
51
- temp_dir = "/tmp/backend_api"
52
- output_path = os.path.join(os.getcwd(), output_dir)
53
-
54
- run(
55
- f"npx openapi-ts "
56
- f"--base {host} "
57
- f"--input {spec_path} "
58
- f"--output {temp_dir if diff_files else output_path} ".split(),
59
- cwd=os.getcwd(),
60
- )
61
- if diff_files:
62
- compare_and_copy(temp_dir, output_dir)
@@ -1,18 +0,0 @@
1
- import tomllib
2
- import os
3
-
4
-
5
- def get_coloco_config():
6
- # Read project toml
7
- if not os.path.exists("pyproject.toml"):
8
- raise LookupError("pyproject.toml not found")
9
- with open("pyproject.toml", "rb") as f:
10
- config = tomllib.load(f)
11
-
12
- # Get coloco config
13
- coloco_config = config.get("tool", {}).get("coloco")
14
- if not coloco_config:
15
- raise LookupError(
16
- "coloco config not found in pyproject.toml under [tool.coloco]"
17
- )
18
- return coloco_config
@@ -1,29 +0,0 @@
1
- <script lang="ts">
2
- import { makeClient, setDefaultClient } from "@coloco/api-client-svelte";
3
- import { route, Router, getRoutes } from "@coloco/router";
4
-
5
- import Index from "./index.svelte";
6
- import NotFound from "./404.svelte";
7
-
8
- const client = makeClient({ baseUrl: import.meta.env.API_HOST });
9
- const routes = getRoutes({
10
- index: Index,
11
- notFound: NotFound,
12
- });
13
-
14
- setDefaultClient(client);
15
- </script>
16
-
17
- <main>
18
- Main Page
19
-
20
- <br /><br />
21
-
22
- <a use:route href="/">Home</a><br />
23
- <a use:route href="/example">Example</a><br />
24
- <a use:route href="/missing">Missing</a>
25
-
26
- <br /><br />
27
-
28
- <Router basePath="/" {routes} />
29
- </main>
@@ -1 +0,0 @@
1
- I am the home page!
@@ -1,10 +0,0 @@
1
- import { defaultPlugins } from '@hey-api/openapi-ts';
2
- import { codegenConfig } from '@coloco/api-client-svelte';
3
-
4
- export default {
5
- plugins: [
6
- ...defaultPlugins,
7
- '@hey-api/client-fetch',
8
- codegenConfig({ name: 'coloco-codegen', outputPath: './api' }),
9
- ],
10
- };
@@ -1,43 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDirs": [
4
- "..",
5
- "../+app/.generated/client/api"
6
- ],
7
- "verbatimModuleSyntax": true,
8
- "isolatedModules": true,
9
- "lib": [
10
- "esnext",
11
- "DOM",
12
- "DOM.Iterable"
13
- ],
14
- "moduleResolution": "bundler",
15
- "module": "esnext",
16
- "noEmit": true,
17
- "target": "esnext",
18
- // Project
19
- "allowJs": true,
20
- "checkJs": true,
21
- "esModuleInterop": true,
22
- "forceConsistentCasingInFileNames": true,
23
- "resolveJsonModule": true,
24
- "skipLibCheck": true,
25
- "sourceMap": true,
26
- "strict": true,
27
- "paths": {
28
- "@api/*": [
29
- "../+app/.generated/client/api/*"
30
- ]
31
- },
32
- },
33
- "include": [
34
- "../**/*.ts",
35
- "../**/*.js",
36
- "../**/*.svelte",
37
- "./vite.config.ts"
38
- ],
39
- "exclude": [
40
- "../node_modules/**",
41
- "../dist/**"
42
- ]
43
- }
@@ -1,2 +0,0 @@
1
- /// <reference types="svelte" />
2
- /// <reference types="vite/client" />
@@ -1,48 +0,0 @@
1
- import path, { dirname, resolve, relative } from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
- import { defineConfig } from 'vite'
4
- import { svelte } from '@sveltejs/vite-plugin-svelte'
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const root = resolve(__dirname, '../');
8
-
9
- // https://vite.dev/config/
10
- export default defineConfig({
11
- plugins: [svelte()],
12
- root: resolve(root, '+app'),
13
- server: {
14
- host: "0.0.0.0",
15
- port: 5173,
16
- },
17
- build: {
18
- outDir: '../dist/app',
19
- emptyOutDir: true, // also necessary
20
- },
21
- clearScreen: false,
22
- resolve: {
23
- // @ts-ignore
24
- alias: [{
25
- find: './api',
26
- customResolver: (_, filePath: string) => {
27
- const subFolder = path.relative(root, dirname(filePath));
28
- const apiFile = resolve(root, `+app/.generated/client/api/${subFolder}/api.ts`);
29
- return apiFile;
30
- }
31
- },
32
- // @ts-ignore
33
- {
34
- find: '@api',
35
- replacement: '/.generated/client/api'
36
- },
37
- // @ts-ignore
38
- {
39
- find: '@app/',
40
- replacement: '/'
41
- },
42
- // @ts-ignore
43
- {
44
- find: '@root',
45
- replacement: '/..'
46
- }]
47
- }
48
- })
@@ -1,6 +0,0 @@
1
- .env
2
- node_modules
3
- dist
4
- +app/.generated
5
- .vite
6
- __pycache__
@@ -1,3 +0,0 @@
1
- # {{ project_name }}
2
-
3
- A kit for creating FastAPI + Svelte applications
@@ -1,7 +0,0 @@
1
- <script lang="ts">
2
- import { test } from "./api";
3
-
4
- const results = test({ name: "Testy McTesterson" });
5
- </script>
6
-
7
- Calling server... {$results.loading} - {$results.data} - {$results.error}
@@ -1,3 +0,0 @@
1
- from coloco import create_app
2
-
3
- app = create_app(name="{{ project_name }}")
@@ -1,13 +0,0 @@
1
- [project]
2
- name = "{{ project_name }}"
3
- version = "0.1.0"
4
- description = "Your project description here"
5
- readme = "README.md"
6
- requires-python = ">=3.11"
7
- dependencies = [
8
- "coloco>=0.2.0",
9
- ]
10
-
11
- [tool.coloco]
12
- app = "main.app"
13
- migrations_dir = "./+migrations"
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "./+node/tsconfig.json"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes