alchemy 0.32.0 → 0.32.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Assets } from "./assets.ts";
|
|
1
|
+
import type { Assets } from "./assets.ts";
|
|
2
2
|
import type { Bindings } from "./bindings.ts";
|
|
3
3
|
import type { WebsiteProps } from "./website.ts";
|
|
4
|
-
import { Worker } from "./worker.ts";
|
|
4
|
+
import type { Worker } from "./worker.ts";
|
|
5
5
|
/**
|
|
6
6
|
* Properties for creating an Astro resource.
|
|
7
7
|
* Extends WebsiteProps, allowing customization of the underlying Website.
|
|
@@ -59,5 +59,5 @@ export type Astro<B extends Bindings> = B extends {
|
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
export declare function Astro<B extends Bindings>(id: string, props
|
|
62
|
+
export declare function Astro<B extends Bindings>(id: string, props: AstroProps<B>): Promise<Astro<B>>;
|
|
63
63
|
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/cloudflare/astro.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/cloudflare/astro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;CAAG;AAE1E;;;;GAIG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,GAAG,CAAA;CAAE,GAC7D,KAAK,GACL,MAAM,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,KAAK,CAAC,CAAC,SAAS,QAAQ,EAC5C,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAsBnB"}
|
package/lib/cloudflare/astro.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { writeFile } from "node:fs/promises";
|
|
2
1
|
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { Exec } from "../os/exec.js";
|
|
5
|
-
import { Scope } from "../scope.js";
|
|
6
|
-
import { Assets } from "./assets.js";
|
|
7
|
-
import { DEFAULT_COMPATIBILITY_DATE, Worker, } from "./worker.js";
|
|
8
|
-
import { WranglerJson } from "./wrangler.json.js";
|
|
2
|
+
import { Website } from "./website.js";
|
|
9
3
|
/**
|
|
10
4
|
* Creates and deploys an Astro application using the Cloudflare adapter.
|
|
11
5
|
*
|
|
@@ -56,78 +50,16 @@ export async function Astro(id, props) {
|
|
|
56
50
|
const assetsDir = typeof props?.assets === "string"
|
|
57
51
|
? props?.assets
|
|
58
52
|
: (props?.assets?.dist ?? "dist");
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const wranglerMain = typeof wrangler === "object"
|
|
70
|
-
? (wrangler.main ?? props?.main)
|
|
71
|
-
: props?.main;
|
|
72
|
-
const workerName = props?.name ?? id;
|
|
73
|
-
const workerProps = {
|
|
74
|
-
...props,
|
|
75
|
-
compatibilityDate: props?.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
|
|
76
|
-
compatibilityFlags: [
|
|
77
|
-
"nodejs_compat",
|
|
78
|
-
...(props?.compatibilityFlags ?? []),
|
|
79
|
-
],
|
|
80
|
-
name: workerName,
|
|
81
|
-
entrypoint: main,
|
|
82
|
-
assets: {
|
|
83
|
-
html_handling: "auto-trailing-slash",
|
|
84
|
-
not_found_handling: "single-page-application",
|
|
85
|
-
run_worker_first: false,
|
|
86
|
-
...(typeof props?.assets === "string" ? {} : props?.assets),
|
|
87
|
-
},
|
|
88
|
-
script: props?.main
|
|
89
|
-
? undefined
|
|
90
|
-
: `
|
|
91
|
-
export default {
|
|
92
|
-
async fetch(request, env) {
|
|
93
|
-
return new Response("Not Found", { status: 404 });
|
|
94
|
-
},
|
|
95
|
-
};`,
|
|
96
|
-
url: true,
|
|
97
|
-
adopt: true,
|
|
98
|
-
};
|
|
99
|
-
if (wrangler) {
|
|
100
|
-
await WranglerJson("wrangler.jsonc", {
|
|
101
|
-
path: wranglerPath,
|
|
102
|
-
worker: workerProps,
|
|
103
|
-
main: wranglerMain,
|
|
104
|
-
// hard-code the assets directory because we haven't yet included the assets binding
|
|
105
|
-
assets: {
|
|
106
|
-
binding: "ASSETS",
|
|
107
|
-
directory: assetsDir,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (props?.command) {
|
|
112
|
-
await Exec("build", {
|
|
113
|
-
cwd,
|
|
114
|
-
command: props?.command,
|
|
115
|
-
env: props?.env,
|
|
116
|
-
memoize: props?.memoize,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
await writeFile(path.join(cwd, assetsDir, ".assetsignore"), ["_worker.js", "_routes.json"].join("\n"));
|
|
120
|
-
return (await Worker("worker", {
|
|
121
|
-
...workerProps,
|
|
122
|
-
bindings: {
|
|
123
|
-
...workerProps.bindings,
|
|
124
|
-
// we don't include the Assets binding until after build to make sure the asset manifest is correct
|
|
125
|
-
// we generate the wrangler.json using all the bind
|
|
126
|
-
ASSETS: await Assets("assets", {
|
|
127
|
-
path: assetsDir,
|
|
128
|
-
}),
|
|
129
|
-
},
|
|
130
|
-
}));
|
|
53
|
+
return Website(id, {
|
|
54
|
+
...props,
|
|
55
|
+
noBundle: props.noBundle ?? true,
|
|
56
|
+
main,
|
|
57
|
+
assets: {
|
|
58
|
+
dist: assetsDir,
|
|
59
|
+
not_found_handling: "none",
|
|
60
|
+
run_worker_first: false,
|
|
61
|
+
},
|
|
62
|
+
wrangler,
|
|
131
63
|
});
|
|
132
64
|
}
|
|
133
65
|
//# sourceMappingURL=astro.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.js","sourceRoot":"","sources":["../../src/cloudflare/astro.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"astro.js","sourceRoot":"","sources":["../../src/cloudflare/astro.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAkBvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,EAAU,EACV,KAAoB;IAEpB,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAQ,IAAI,IAAI,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACrE,MAAM,SAAS,GACb,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ;QAC/B,CAAC,CAAC,KAAK,EAAE,MAAM;QACf,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC,EAAE,EAAE;QACjB,GAAG,KAAK;QACR,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,IAAI;QACJ,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,kBAAkB,EAAE,MAAM;YAC1B,gBAAgB,EAAE,KAAK;SACxB;QACD,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/cloudflare/astro.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { writeFile } from "node:fs/promises";
|
|
2
1
|
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { Exec } from "../os/exec.ts";
|
|
5
|
-
import { Scope } from "../scope.ts";
|
|
6
|
-
import { Assets } from "./assets.ts";
|
|
2
|
+
import type { Assets } from "./assets.ts";
|
|
7
3
|
import type { Bindings } from "./bindings.ts";
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
Worker,
|
|
12
|
-
type WorkerProps,
|
|
13
|
-
} from "./worker.ts";
|
|
14
|
-
import { WranglerJson } from "./wrangler.json.ts";
|
|
4
|
+
import type { WebsiteProps } from "./website.ts";
|
|
5
|
+
import { Website } from "./website.ts";
|
|
6
|
+
import type { Worker } from "./worker.ts";
|
|
15
7
|
|
|
16
8
|
/**
|
|
17
9
|
* Properties for creating an Astro resource.
|
|
@@ -71,7 +63,7 @@ export type Astro<B extends Bindings> = B extends { ASSETS: any }
|
|
|
71
63
|
*/
|
|
72
64
|
export async function Astro<B extends Bindings>(
|
|
73
65
|
id: string,
|
|
74
|
-
props
|
|
66
|
+
props: AstroProps<B>,
|
|
75
67
|
): Promise<Astro<B>> {
|
|
76
68
|
if (props?.bindings?.ASSETS) {
|
|
77
69
|
throw new Error("ASSETS binding is reserved for internal use");
|
|
@@ -83,94 +75,15 @@ export async function Astro<B extends Bindings>(
|
|
|
83
75
|
? props?.assets
|
|
84
76
|
: (props?.assets?.dist ?? "dist");
|
|
85
77
|
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
return Website(id, {
|
|
79
|
+
...props,
|
|
80
|
+
noBundle: props.noBundle ?? true,
|
|
81
|
+
main,
|
|
82
|
+
assets: {
|
|
83
|
+
dist: assetsDir,
|
|
84
|
+
not_found_handling: "none",
|
|
85
|
+
run_worker_first: false,
|
|
90
86
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const fileName =
|
|
94
|
-
typeof wrangler === "boolean"
|
|
95
|
-
? "wrangler.jsonc"
|
|
96
|
-
: typeof wrangler === "string"
|
|
97
|
-
? wrangler
|
|
98
|
-
: (wrangler?.path ?? "wrangler.jsonc");
|
|
99
|
-
const wranglerPath =
|
|
100
|
-
fileName && path.relative(cwd, path.join(cwd, fileName));
|
|
101
|
-
const wranglerMain =
|
|
102
|
-
typeof wrangler === "object"
|
|
103
|
-
? (wrangler.main ?? props?.main)
|
|
104
|
-
: props?.main;
|
|
105
|
-
|
|
106
|
-
const workerName = props?.name ?? id;
|
|
107
|
-
|
|
108
|
-
const workerProps = {
|
|
109
|
-
...props,
|
|
110
|
-
compatibilityDate:
|
|
111
|
-
props?.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
|
|
112
|
-
compatibilityFlags: [
|
|
113
|
-
"nodejs_compat",
|
|
114
|
-
...(props?.compatibilityFlags ?? []),
|
|
115
|
-
],
|
|
116
|
-
name: workerName,
|
|
117
|
-
entrypoint: main,
|
|
118
|
-
assets: {
|
|
119
|
-
html_handling: "auto-trailing-slash",
|
|
120
|
-
not_found_handling: "single-page-application",
|
|
121
|
-
run_worker_first: false,
|
|
122
|
-
...(typeof props?.assets === "string" ? {} : props?.assets),
|
|
123
|
-
},
|
|
124
|
-
script: props?.main
|
|
125
|
-
? undefined
|
|
126
|
-
: `
|
|
127
|
-
export default {
|
|
128
|
-
async fetch(request, env) {
|
|
129
|
-
return new Response("Not Found", { status: 404 });
|
|
130
|
-
},
|
|
131
|
-
};`,
|
|
132
|
-
url: true,
|
|
133
|
-
adopt: true,
|
|
134
|
-
} as WorkerProps<any> & { name: string };
|
|
135
|
-
|
|
136
|
-
if (wrangler) {
|
|
137
|
-
await WranglerJson("wrangler.jsonc", {
|
|
138
|
-
path: wranglerPath,
|
|
139
|
-
worker: workerProps,
|
|
140
|
-
main: wranglerMain,
|
|
141
|
-
// hard-code the assets directory because we haven't yet included the assets binding
|
|
142
|
-
assets: {
|
|
143
|
-
binding: "ASSETS",
|
|
144
|
-
directory: assetsDir,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (props?.command) {
|
|
150
|
-
await Exec("build", {
|
|
151
|
-
cwd,
|
|
152
|
-
command: props?.command,
|
|
153
|
-
env: props?.env,
|
|
154
|
-
memoize: props?.memoize,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
await writeFile(
|
|
159
|
-
path.join(cwd, assetsDir, ".assetsignore"),
|
|
160
|
-
["_worker.js", "_routes.json"].join("\n"),
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
return (await Worker("worker", {
|
|
164
|
-
...workerProps,
|
|
165
|
-
bindings: {
|
|
166
|
-
...workerProps.bindings,
|
|
167
|
-
// we don't include the Assets binding until after build to make sure the asset manifest is correct
|
|
168
|
-
// we generate the wrangler.json using all the bind
|
|
169
|
-
ASSETS: await Assets("assets", {
|
|
170
|
-
path: assetsDir,
|
|
171
|
-
}),
|
|
172
|
-
},
|
|
173
|
-
} as WorkerProps<any> & { name: string })) as Website<B>;
|
|
174
|
-
},
|
|
175
|
-
);
|
|
87
|
+
wrangler,
|
|
88
|
+
});
|
|
176
89
|
}
|