create-cloesce 0.3.0 → 0.3.3
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/cli.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var i=Object.create;var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var f=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of p(r))!d.call(e,o)&&o!==t&&a(e,o,{get:()=>r[o],enumerable:!(n=m(r,o))||n.enumerable});return e};var v=(e,r,t)=>(t=e!=null?i(u(e)):{},f(r||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e));var l=require("create-create-app"),s=require("path"),c=v(require("fs")),g=(0,s.resolve)(__dirname,"..","templates"),b=`
|
|
3
|
+
Ensure cloesce has been installed (https://cloesce.pages.dev/ch1-1-installation).
|
|
4
|
+
|
|
3
5
|
To build your Cloesce project, run:
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
+
- cloesce compile
|
|
7
|
+
- cloesce migrate --all Initial
|
|
6
8
|
- npm run migrate:wrangler
|
|
7
9
|
|
|
8
10
|
To start your Cloesce project in development mode, in seperate terminals, run:
|
|
9
11
|
- npm run start:dev
|
|
10
12
|
- npm run start:web
|
|
11
|
-
`;(0,
|
|
13
|
+
`;(0,l.create)("create-cloesce",{templateRoot:g,promptForLicense:!1,promptForDescription:!1,promptForEmail:!1,defaultLicense:"UNLICENSED",after:async({packageDir:e})=>{c.default.mkdirSync((0,s.resolve)(e,"migrations"))},caveat:b});
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Every .clo and .cloesce file under these paths will be included in the generated client API
|
|
3
|
+
"src_paths": ["./src/schema"],
|
|
4
|
+
|
|
5
|
+
// When cloece compile is invoked, the generated client API
|
|
6
|
+
// will use this URL
|
|
7
|
+
//
|
|
8
|
+
// If you have multiple environments (e.g., dev, staging, prod), you can make
|
|
9
|
+
// multiple `cloesce.jsonc` files with their respective prefix `<env>.cloesce.jsonc`
|
|
10
|
+
// and set the `workers_url` accordingly.
|
|
11
|
+
"workers_url": "http://localhost:5000/api",
|
|
12
|
+
|
|
13
|
+
// or "toml"
|
|
14
|
+
"wrangler_config_format": "jsonc"
|
|
15
|
+
}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "cloesce compile && wrangler build",
|
|
8
|
-
"migrate:cloesce": "cloesce migrate db",
|
|
9
7
|
"migrate:wrangler": "wrangler d1 migrations apply db",
|
|
10
8
|
"start:dev": "wrangler dev --port 5000",
|
|
11
9
|
"start:web": "vite",
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// It does not replace the wrangler config, but does result in a generated version.
|
|
3
3
|
env {
|
|
4
4
|
// The `d1` block describes all D1 database bindings
|
|
5
|
-
d1 {
|
|
6
|
-
db
|
|
5
|
+
d1 {
|
|
6
|
+
db
|
|
7
7
|
// db2
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
// The `r2` block describes all R2 bucket bindings
|
|
11
|
-
r2 {
|
|
12
|
-
bucket
|
|
11
|
+
r2 {
|
|
12
|
+
bucket
|
|
13
13
|
// bucket2
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ model WeatherReport {
|
|
|
26
26
|
primary {
|
|
27
27
|
id: int
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
// A `nav` block describes a relationship between two models.
|
|
31
31
|
// In this case, it is a one-to-many relationship between WeatherReport and Weather,
|
|
32
32
|
// where WeatherReport has many Weathers.
|
|
@@ -35,11 +35,11 @@ model WeatherReport {
|
|
|
35
35
|
// references the `id` field in the WeatherReport model.
|
|
36
36
|
//
|
|
37
37
|
// This will resolve to a navigation field named `weatherEntries` in the WeatherReport model,
|
|
38
|
-
//which is an array of Weather objects.
|
|
38
|
+
// which is an array of Weather objects.
|
|
39
39
|
nav (Weather::weatherReportId) {
|
|
40
40
|
weatherEntries
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
// All fields that are not apart of a block are just regular fields in the table.
|
|
44
44
|
title: string
|
|
45
45
|
description: string
|
|
@@ -51,21 +51,24 @@ model Weather {
|
|
|
51
51
|
primary {
|
|
52
52
|
id: int
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// A `foreign` block describes a one to one relationship between two models.
|
|
56
56
|
// It translates directly to a foreign key constraint in the database (`weatherReportId` references `id` in WeatherReport).
|
|
57
57
|
foreign (WeatherReport::id) {
|
|
58
58
|
weatherReportId
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
|
|
60
61
|
// A `nav` block inside a `foreign` block generates a navigation field,
|
|
61
62
|
// meaning the backend and client will have a WeatherReport object named `weatherReport` nested inside the Weather model.
|
|
62
|
-
nav {
|
|
63
|
+
nav {
|
|
64
|
+
weatherReport
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
r2 (bucket, "weather/photos/{id}.jpg") {
|
|
66
69
|
photo
|
|
67
70
|
}
|
|
68
|
-
|
|
71
|
+
|
|
69
72
|
dateTime: date
|
|
70
73
|
location: string
|
|
71
74
|
temperature: int
|
|
@@ -83,7 +86,7 @@ api Weather {
|
|
|
83
86
|
// In this case, `uploadPhoto` accepts the Wrangler environment (dependency injected),
|
|
84
87
|
// and a stream (the photo to be uploaded).
|
|
85
88
|
post uploadPhoto(self, e: env, s: stream) -> void
|
|
86
|
-
|
|
89
|
+
|
|
87
90
|
// By default, Cloesce will hydrate a `self` instance with all 1:1, KV, R2,
|
|
88
91
|
// and the near side of 1:M/M:M relationships.
|
|
89
92
|
//
|
|
@@ -98,5 +101,7 @@ api Weather {
|
|
|
98
101
|
//
|
|
99
102
|
// In this case, the include tree has only the `photo` field of `Weather`.
|
|
100
103
|
source R2Only for Weather {
|
|
101
|
-
include {
|
|
104
|
+
include {
|
|
105
|
+
photo
|
|
106
|
+
}
|
|
102
107
|
}
|