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?: Partial<AstroProps<B>>): Promise<Astro<B>>;
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":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAEL,MAAM,EAEP,MAAM,aAAa,CAAC;AAGrB;;;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,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAqGnB"}
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"}
@@ -1,11 +1,5 @@
1
- import { writeFile } from "node:fs/promises";
2
1
  import path from "node:path";
3
- import { alchemy } from "../alchemy.js";
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 alchemy.run(id, {
60
- parent: Scope.current,
61
- }, async () => {
62
- const cwd = path.resolve(props?.cwd || process.cwd());
63
- const fileName = typeof wrangler === "boolean"
64
- ? "wrangler.jsonc"
65
- : typeof wrangler === "string"
66
- ? wrangler
67
- : (wrangler?.path ?? "wrangler.jsonc");
68
- const wranglerPath = fileName && path.relative(cwd, path.join(cwd, fileName));
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,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,0BAA0B,EAC1B,MAAM,GAEP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,EAAU,EACV,KAA8B;IAE9B,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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@@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "license": "Apache-2.0",
@@ -1,17 +1,9 @@
1
- import { writeFile } from "node:fs/promises";
2
1
  import path from "node:path";
3
- import { alchemy } from "../alchemy.ts";
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 { Website, WebsiteProps } from "./website.ts";
9
- import {
10
- DEFAULT_COMPATIBILITY_DATE,
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?: Partial<AstroProps<B>>,
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 alchemy.run(
87
- id,
88
- {
89
- parent: Scope.current,
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
- async () => {
92
- const cwd = path.resolve(props?.cwd || process.cwd());
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
  }